repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
olivergondza/jenkins-config-cloner | src/test/java/org/jenkinsci/tools/configcloner/MainTest.java | // Path: src/test/java/org/jenkinsci/tools/configcloner/handler/Helper.java
// public static CommandResponseMatcher stdoutContains(final String expected) {
// return new CommandResponseMatcher("Standard output should contain string " + expected) {
// @Override protected boolean match(Accumulator item, Description desc) {
// return item.stdout().contains(expected);
// }
// };
// }
//
// Path: src/test/java/org/jenkinsci/tools/configcloner/handler/Helper.java
// public static CommandResponseMatcher succeeded() {
// return new CommandResponseMatcher("Command suceeded") {
// @Override protected boolean match(Accumulator item, Description desc) {
// return item.succeeded();
// }
// };
// }
//
// Path: src/main/java/org/jenkinsci/tools/configcloner/CommandResponse.java
// public static class Accumulator extends CommandResponse{
//
// final ByteArrayOutputStream out;
// final ByteArrayOutputStream err;
//
// private Accumulator(final ByteArrayOutputStream out, final ByteArrayOutputStream err) {
//
// super(new PrintStream(out), new PrintStream(err));
//
// this.out = out;
// this.err = err;
// }
//
// public String stdout() {
//
// return asString(out);
// }
//
// public String stdout(final String pattern) {
//
// return decorate(out, pattern);
// }
//
// public String stderr() {
//
// return asString(err);
// }
//
// public String stderr(final String pattern) {
//
// return decorate(err, pattern);
// }
//
// public void dump(final String operation) {
//
// System.out.println(operation + ": " + returnCode());
// System.err.print(stderr("err > %s"));
// System.out.print(stdout("out > %s"));
// }
//
// private String decorate(final ByteArrayOutputStream stream, String pattern) {
//
// if (!pattern.endsWith("\n")) {
//
// pattern += "\n";
// }
//
// final String in = asString(stream);
// if (in.isEmpty()) return "";
//
// final StringBuilder builder = new StringBuilder(in.length());
// for (final String line: asString(stream).split("\n")) {
//
// builder.append(String.format(pattern, line));
// }
//
// return builder.toString();
// }
//
// private String asString(final ByteArrayOutputStream stream) {
//
// try {
//
// return stream.toString("UTF-8");
// } catch (final UnsupportedEncodingException ex) {
//
// throw new AssertionError(ex);
// }
// }
//
// @Override
// public Accumulator returnCode(final int ret) {
//
// return (Accumulator) super.returnCode(ret);
// }
// }
//
// Path: src/main/java/org/jenkinsci/tools/configcloner/handler/Usage.java
// public class Usage implements Handler {
//
// private final Main main;
//
// public Usage(final Main main) {
// this.main = main;
// }
//
// public CommandResponse run(final CommandResponse response) {
// response.out().println("Usage: ");
// for(Handler handler: main.commandMapping().values()) {
// final PrintStream o = response.out();
// o.println();
// o.format("%-10s %s\n", handler.name(), handler.description());
// new CmdLineParser(handler).printUsage(o);
// }
//
// return response;
// }
//
// public String name() {
// return "help";
// }
//
// public String description() {
// return "Print usage";
// }
// }
| import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.text.IsEmptyString.isEmptyString;
import static org.jenkinsci.tools.configcloner.handler.Helper.stdoutContains;
import static org.jenkinsci.tools.configcloner.handler.Helper.succeeded;
import org.jenkinsci.tools.configcloner.CommandResponse.Accumulator;
import org.jenkinsci.tools.configcloner.handler.Usage;
import org.junit.Test; | package org.jenkinsci.tools.configcloner;
public class MainTest {
final Accumulator rsp = CommandResponse.accumulate();
@Test
public void getUsageWhenNoArgsProvided() {
assertThat(run().getHandler(), instanceOf(Usage.class));
}
@Test
public void getUsageWhenInvalidArgsProvided() {
assertThat(run("no-such-command").getHandler(), instanceOf(Usage.class));
}
@Test
public void failedValidationShouldInvokeUsage() {
run("job", "invalid-arg");
assertThat(rsp, not(succeeded()));
assertThat(rsp.stderr(), not(isEmptyString())); | // Path: src/test/java/org/jenkinsci/tools/configcloner/handler/Helper.java
// public static CommandResponseMatcher stdoutContains(final String expected) {
// return new CommandResponseMatcher("Standard output should contain string " + expected) {
// @Override protected boolean match(Accumulator item, Description desc) {
// return item.stdout().contains(expected);
// }
// };
// }
//
// Path: src/test/java/org/jenkinsci/tools/configcloner/handler/Helper.java
// public static CommandResponseMatcher succeeded() {
// return new CommandResponseMatcher("Command suceeded") {
// @Override protected boolean match(Accumulator item, Description desc) {
// return item.succeeded();
// }
// };
// }
//
// Path: src/main/java/org/jenkinsci/tools/configcloner/CommandResponse.java
// public static class Accumulator extends CommandResponse{
//
// final ByteArrayOutputStream out;
// final ByteArrayOutputStream err;
//
// private Accumulator(final ByteArrayOutputStream out, final ByteArrayOutputStream err) {
//
// super(new PrintStream(out), new PrintStream(err));
//
// this.out = out;
// this.err = err;
// }
//
// public String stdout() {
//
// return asString(out);
// }
//
// public String stdout(final String pattern) {
//
// return decorate(out, pattern);
// }
//
// public String stderr() {
//
// return asString(err);
// }
//
// public String stderr(final String pattern) {
//
// return decorate(err, pattern);
// }
//
// public void dump(final String operation) {
//
// System.out.println(operation + ": " + returnCode());
// System.err.print(stderr("err > %s"));
// System.out.print(stdout("out > %s"));
// }
//
// private String decorate(final ByteArrayOutputStream stream, String pattern) {
//
// if (!pattern.endsWith("\n")) {
//
// pattern += "\n";
// }
//
// final String in = asString(stream);
// if (in.isEmpty()) return "";
//
// final StringBuilder builder = new StringBuilder(in.length());
// for (final String line: asString(stream).split("\n")) {
//
// builder.append(String.format(pattern, line));
// }
//
// return builder.toString();
// }
//
// private String asString(final ByteArrayOutputStream stream) {
//
// try {
//
// return stream.toString("UTF-8");
// } catch (final UnsupportedEncodingException ex) {
//
// throw new AssertionError(ex);
// }
// }
//
// @Override
// public Accumulator returnCode(final int ret) {
//
// return (Accumulator) super.returnCode(ret);
// }
// }
//
// Path: src/main/java/org/jenkinsci/tools/configcloner/handler/Usage.java
// public class Usage implements Handler {
//
// private final Main main;
//
// public Usage(final Main main) {
// this.main = main;
// }
//
// public CommandResponse run(final CommandResponse response) {
// response.out().println("Usage: ");
// for(Handler handler: main.commandMapping().values()) {
// final PrintStream o = response.out();
// o.println();
// o.format("%-10s %s\n", handler.name(), handler.description());
// new CmdLineParser(handler).printUsage(o);
// }
//
// return response;
// }
//
// public String name() {
// return "help";
// }
//
// public String description() {
// return "Print usage";
// }
// }
// Path: src/test/java/org/jenkinsci/tools/configcloner/MainTest.java
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.text.IsEmptyString.isEmptyString;
import static org.jenkinsci.tools.configcloner.handler.Helper.stdoutContains;
import static org.jenkinsci.tools.configcloner.handler.Helper.succeeded;
import org.jenkinsci.tools.configcloner.CommandResponse.Accumulator;
import org.jenkinsci.tools.configcloner.handler.Usage;
import org.junit.Test;
package org.jenkinsci.tools.configcloner;
public class MainTest {
final Accumulator rsp = CommandResponse.accumulate();
@Test
public void getUsageWhenNoArgsProvided() {
assertThat(run().getHandler(), instanceOf(Usage.class));
}
@Test
public void getUsageWhenInvalidArgsProvided() {
assertThat(run("no-such-command").getHandler(), instanceOf(Usage.class));
}
@Test
public void failedValidationShouldInvokeUsage() {
run("job", "invalid-arg");
assertThat(rsp, not(succeeded()));
assertThat(rsp.stderr(), not(isEmptyString())); | assertThat(rsp, stdoutContains("Usage:")); |
olivergondza/jenkins-config-cloner | src/main/java/org/jenkinsci/tools/configcloner/handler/InvalidUsage.java | // Path: src/main/java/org/jenkinsci/tools/configcloner/CommandResponse.java
// public class CommandResponse {
//
// private int returnCode = -42;
// private final PrintStream outputStream;
// private final PrintStream errorStream;
//
// public static CommandResponse system() {
// return new CommandResponse(System.out, System.err);
// }
//
// public CommandResponse(final PrintStream out, final PrintStream err) {
//
// if (out == null) throw new IllegalArgumentException("out is null");
// if (err == null) throw new IllegalArgumentException("err is null");
//
// this.returnCode = 0;
// this.outputStream = out;
// this.errorStream = err;
// }
//
// public CommandResponse returnCode(final int ret) {
//
// returnCode = ret;
// return this;
// }
//
// public int returnCode() {
//
// return returnCode;
// }
//
// public boolean succeeded() {
//
// return returnCode() == 0;
// }
//
// public PrintStream out() {
//
// return outputStream;
// }
//
// public PrintStream err() {
//
// return errorStream;
// }
//
// public static Accumulator accumulate() {
//
// return new Accumulator(new ByteArrayOutputStream(), new ByteArrayOutputStream());
// }
//
// public CommandResponse merge(final Accumulator response) {
//
// if (returnCode == 0) {
// returnCode = response.returnCode();
// }
// outputStream.append(response.stdout());
// errorStream.append(response.stderr());
//
// return this;
// }
//
// public static class Accumulator extends CommandResponse{
//
// final ByteArrayOutputStream out;
// final ByteArrayOutputStream err;
//
// private Accumulator(final ByteArrayOutputStream out, final ByteArrayOutputStream err) {
//
// super(new PrintStream(out), new PrintStream(err));
//
// this.out = out;
// this.err = err;
// }
//
// public String stdout() {
//
// return asString(out);
// }
//
// public String stdout(final String pattern) {
//
// return decorate(out, pattern);
// }
//
// public String stderr() {
//
// return asString(err);
// }
//
// public String stderr(final String pattern) {
//
// return decorate(err, pattern);
// }
//
// public void dump(final String operation) {
//
// System.out.println(operation + ": " + returnCode());
// System.err.print(stderr("err > %s"));
// System.out.print(stdout("out > %s"));
// }
//
// private String decorate(final ByteArrayOutputStream stream, String pattern) {
//
// if (!pattern.endsWith("\n")) {
//
// pattern += "\n";
// }
//
// final String in = asString(stream);
// if (in.isEmpty()) return "";
//
// final StringBuilder builder = new StringBuilder(in.length());
// for (final String line: asString(stream).split("\n")) {
//
// builder.append(String.format(pattern, line));
// }
//
// return builder.toString();
// }
//
// private String asString(final ByteArrayOutputStream stream) {
//
// try {
//
// return stream.toString("UTF-8");
// } catch (final UnsupportedEncodingException ex) {
//
// throw new AssertionError(ex);
// }
// }
//
// @Override
// public Accumulator returnCode(final int ret) {
//
// return (Accumulator) super.returnCode(ret);
// }
// }
// }
| import org.jenkinsci.tools.configcloner.CommandResponse;
import org.kohsuke.args4j.CmdLineParser; | /*
* The MIT License
*
* Copyright (c) 2013 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.jenkinsci.tools.configcloner.handler;
public class InvalidUsage implements Handler {
private final Exception ex;
private final CmdLineParser parser;
public InvalidUsage(final CmdLineParser parser, final Exception ex) {
this.ex = ex;
this.parser = parser;
}
| // Path: src/main/java/org/jenkinsci/tools/configcloner/CommandResponse.java
// public class CommandResponse {
//
// private int returnCode = -42;
// private final PrintStream outputStream;
// private final PrintStream errorStream;
//
// public static CommandResponse system() {
// return new CommandResponse(System.out, System.err);
// }
//
// public CommandResponse(final PrintStream out, final PrintStream err) {
//
// if (out == null) throw new IllegalArgumentException("out is null");
// if (err == null) throw new IllegalArgumentException("err is null");
//
// this.returnCode = 0;
// this.outputStream = out;
// this.errorStream = err;
// }
//
// public CommandResponse returnCode(final int ret) {
//
// returnCode = ret;
// return this;
// }
//
// public int returnCode() {
//
// return returnCode;
// }
//
// public boolean succeeded() {
//
// return returnCode() == 0;
// }
//
// public PrintStream out() {
//
// return outputStream;
// }
//
// public PrintStream err() {
//
// return errorStream;
// }
//
// public static Accumulator accumulate() {
//
// return new Accumulator(new ByteArrayOutputStream(), new ByteArrayOutputStream());
// }
//
// public CommandResponse merge(final Accumulator response) {
//
// if (returnCode == 0) {
// returnCode = response.returnCode();
// }
// outputStream.append(response.stdout());
// errorStream.append(response.stderr());
//
// return this;
// }
//
// public static class Accumulator extends CommandResponse{
//
// final ByteArrayOutputStream out;
// final ByteArrayOutputStream err;
//
// private Accumulator(final ByteArrayOutputStream out, final ByteArrayOutputStream err) {
//
// super(new PrintStream(out), new PrintStream(err));
//
// this.out = out;
// this.err = err;
// }
//
// public String stdout() {
//
// return asString(out);
// }
//
// public String stdout(final String pattern) {
//
// return decorate(out, pattern);
// }
//
// public String stderr() {
//
// return asString(err);
// }
//
// public String stderr(final String pattern) {
//
// return decorate(err, pattern);
// }
//
// public void dump(final String operation) {
//
// System.out.println(operation + ": " + returnCode());
// System.err.print(stderr("err > %s"));
// System.out.print(stdout("out > %s"));
// }
//
// private String decorate(final ByteArrayOutputStream stream, String pattern) {
//
// if (!pattern.endsWith("\n")) {
//
// pattern += "\n";
// }
//
// final String in = asString(stream);
// if (in.isEmpty()) return "";
//
// final StringBuilder builder = new StringBuilder(in.length());
// for (final String line: asString(stream).split("\n")) {
//
// builder.append(String.format(pattern, line));
// }
//
// return builder.toString();
// }
//
// private String asString(final ByteArrayOutputStream stream) {
//
// try {
//
// return stream.toString("UTF-8");
// } catch (final UnsupportedEncodingException ex) {
//
// throw new AssertionError(ex);
// }
// }
//
// @Override
// public Accumulator returnCode(final int ret) {
//
// return (Accumulator) super.returnCode(ret);
// }
// }
// }
// Path: src/main/java/org/jenkinsci/tools/configcloner/handler/InvalidUsage.java
import org.jenkinsci.tools.configcloner.CommandResponse;
import org.kohsuke.args4j.CmdLineParser;
/*
* The MIT License
*
* Copyright (c) 2013 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package org.jenkinsci.tools.configcloner.handler;
public class InvalidUsage implements Handler {
private final Exception ex;
private final CmdLineParser parser;
public InvalidUsage(final CmdLineParser parser, final Exception ex) {
this.ex = ex;
this.parser = parser;
}
| public CommandResponse run(final CommandResponse response) { |
Naoghuman/lib-preferences | src/test/java/com/github/naoghuman/lib/preferences/core/PreferencesFactoryTest.java | // Path: src/test/java/dummy/module/scope/DummyModuleScope.java
// public class DummyModuleScope {
//
// }
| import dummy.module.scope.DummyModuleScope;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
| /*
* Copyright (C) 2014 - 2018 Naoghuman's dream
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.naoghuman.lib.preferences.core;
/**
* UnitTests to test the factory {@link com.github.naoghuman.lib.preferences.core.PreferencesFactory}.
*
* @since 0.6.0
* @version 0.6.0
* @author Naoghuman
* @see com.github.naoghuman.lib.preferences.core.PreferencesFactory
*/
public class PreferencesFactoryTest {
public PreferencesFactoryTest() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
// #########################################################################
@Test(expected = NullPointerException.class)
public void firstStepModuleThrowsNullPointerException() {
PreferencesFactory.create()
.module(null)
.key("dummy.key")
.get("dummy.default.value");
}
// #########################################################################
@Test(expected = NullPointerException.class)
public void secondStepKeyThrowsNullPointerException() {
PreferencesFactory.create()
| // Path: src/test/java/dummy/module/scope/DummyModuleScope.java
// public class DummyModuleScope {
//
// }
// Path: src/test/java/com/github/naoghuman/lib/preferences/core/PreferencesFactoryTest.java
import dummy.module.scope.DummyModuleScope;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
/*
* Copyright (C) 2014 - 2018 Naoghuman's dream
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.github.naoghuman.lib.preferences.core;
/**
* UnitTests to test the factory {@link com.github.naoghuman.lib.preferences.core.PreferencesFactory}.
*
* @since 0.6.0
* @version 0.6.0
* @author Naoghuman
* @see com.github.naoghuman.lib.preferences.core.PreferencesFactory
*/
public class PreferencesFactoryTest {
public PreferencesFactoryTest() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
// #########################################################################
@Test(expected = NullPointerException.class)
public void firstStepModuleThrowsNullPointerException() {
PreferencesFactory.create()
.module(null)
.key("dummy.key")
.get("dummy.default.value");
}
// #########################################################################
@Test(expected = NullPointerException.class)
public void secondStepKeyThrowsNullPointerException() {
PreferencesFactory.create()
| .module(DummyModuleScope.class)
|
perfmark/perfmark | java6/src/main/java/io/perfmark/java6/SecretSynchronizedMarkHolderProvider.java | // Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
//
// public static final int NO_MAX_MARKS = -1;
//
// public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void start(long gen, String taskName, long nanoTime);
//
// public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void link(long gen, long linkId);
//
// public abstract void stop(long gen, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void stop(long gen, String taskName, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
//
// public abstract void event(long gen, String eventName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
//
// public abstract void attachTag(long gen, String tagName, long tagId);
//
// public abstract void attachKeyedTag(long gen, String name, String value);
//
// public abstract void attachKeyedTag(long gen, String name, long value0);
//
// public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
//
// public abstract void resetForTest();
//
// public abstract List<Mark> read(boolean concurrentWrites);
//
// public int maxMarks() {
// return NO_MAX_MARKS;
// }
//
// protected MarkHolder() {}
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolderProvider.java
// public abstract class MarkHolderProvider {
//
// protected MarkHolderProvider() {}
//
// /**
// * To be removed in 0.26.0
// *
// * @return the new MarkHolder for the current thread.
// */
// @Deprecated
// public MarkHolder create() {
// throw new UnsupportedOperationException();
// }
//
// /**
// * Creates a new MarkHolder. Mark holders are always mutated by the thread that created them, (e.g. THIS thread),
// * but may be read by other threads.
// *
// * @param markHolderId the Unique ID associated with the Mark Holder. This exists as a work around to Java's
// * thread ID, which does not guarantee they will not be reused.
// * @return the new MarkHolder for the current thread.
// * @since 0.24.0
// */
// public MarkHolder create(long markHolderId) {
// return create();
// }
// }
| import io.perfmark.impl.MarkHolder;
import io.perfmark.impl.MarkHolderProvider; | /*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java6;
final class SecretSynchronizedMarkHolderProvider {
public static final class SynchronizedMarkHolderProvider extends MarkHolderProvider {
public SynchronizedMarkHolderProvider() {}
@Override
@SuppressWarnings("deprecation") | // Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
//
// public static final int NO_MAX_MARKS = -1;
//
// public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void start(long gen, String taskName, long nanoTime);
//
// public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void link(long gen, long linkId);
//
// public abstract void stop(long gen, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void stop(long gen, String taskName, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
//
// public abstract void event(long gen, String eventName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
//
// public abstract void attachTag(long gen, String tagName, long tagId);
//
// public abstract void attachKeyedTag(long gen, String name, String value);
//
// public abstract void attachKeyedTag(long gen, String name, long value0);
//
// public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
//
// public abstract void resetForTest();
//
// public abstract List<Mark> read(boolean concurrentWrites);
//
// public int maxMarks() {
// return NO_MAX_MARKS;
// }
//
// protected MarkHolder() {}
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolderProvider.java
// public abstract class MarkHolderProvider {
//
// protected MarkHolderProvider() {}
//
// /**
// * To be removed in 0.26.0
// *
// * @return the new MarkHolder for the current thread.
// */
// @Deprecated
// public MarkHolder create() {
// throw new UnsupportedOperationException();
// }
//
// /**
// * Creates a new MarkHolder. Mark holders are always mutated by the thread that created them, (e.g. THIS thread),
// * but may be read by other threads.
// *
// * @param markHolderId the Unique ID associated with the Mark Holder. This exists as a work around to Java's
// * thread ID, which does not guarantee they will not be reused.
// * @return the new MarkHolder for the current thread.
// * @since 0.24.0
// */
// public MarkHolder create(long markHolderId) {
// return create();
// }
// }
// Path: java6/src/main/java/io/perfmark/java6/SecretSynchronizedMarkHolderProvider.java
import io.perfmark.impl.MarkHolder;
import io.perfmark.impl.MarkHolderProvider;
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java6;
final class SecretSynchronizedMarkHolderProvider {
public static final class SynchronizedMarkHolderProvider extends MarkHolderProvider {
public SynchronizedMarkHolderProvider() {}
@Override
@SuppressWarnings("deprecation") | public MarkHolder create() { |
perfmark/perfmark | impl/src/main/java/io/perfmark/impl/SecretPerfMarkImpl.java | // Path: api/src/main/java/io/perfmark/Impl.java
// public class Impl {
// static final String NO_TAG_NAME = "";
// static final long NO_TAG_ID = Long.MIN_VALUE;
// /**
// * This value is current {@link Long#MIN_VALUE}, but it could also be {@code 0}. The invariant
// * {@code NO_LINK_ID == -NO_LINK_ID} must be maintained to work when PerfMark is disabled.
// */
// private static final long NO_LINK_ID = Long.MIN_VALUE;
//
// static final Tag NO_TAG = new Tag(Impl.NO_TAG_NAME, Impl.NO_TAG_ID);
// static final Link NO_LINK = new Link(Impl.NO_LINK_ID);
//
// /** The Noop implementation */
// protected Impl(Tag key) {
// if (key != NO_TAG) {
// throw new AssertionError("nope");
// }
// }
//
// protected void setEnabled(boolean value) {}
//
// protected <T> void startTask(T taskNameObject, StringFunction<? super T> taskNameFunc) {}
//
// protected void startTask(String taskName, Tag tag) {}
//
// protected void startTask(String taskName) {}
//
// protected void startTask(String taskName, String subTaskName) {}
//
// protected void event(String eventName, Tag tag) {}
//
// protected void event(String eventName) {}
//
// protected void event(String eventName, String subEventName) {}
//
// protected void stopTask() {}
//
// protected void stopTask(String taskName, Tag tag) {}
//
// protected void stopTask(String taskName) {}
//
// protected void stopTask(String taskName, String subTaskName) {}
//
// protected Link linkOut() {
// return NO_LINK;
// }
//
// protected void linkIn(Link link) {}
//
// protected void attachTag(Tag tag) {}
//
// protected void attachTag(String tagName, String tagValue) {}
//
// protected void attachTag(String tagName, long tagValue) {}
//
// protected void attachTag(String tagName, long tagValue0, long tagValue1) {}
//
// protected <T> void attachTag(
// String tagName, T tagObject, StringFunction<? super T> stringFunction) {}
//
// protected Tag createTag(@Nullable String tagName, long tagId) {
// return NO_TAG;
// }
//
// @Nullable
// protected static String unpackTagName(Tag tag) {
// return tag.tagName;
// }
//
// protected static long unpackTagId(Tag tag) {
// return tag.tagId;
// }
//
// protected static long unpackLinkId(Link link) {
// return link.linkId;
// }
//
// protected static Tag packTag(@Nullable String tagName, long tagId) {
// return new Tag(tagName, tagId);
// }
//
// protected static Link packLink(long linkId) {
// return new Link(linkId);
// }
// }
//
// Path: api/src/main/java/io/perfmark/Link.java
// public final class Link {
//
// final long linkId;
//
// Link(long linkId) {
// this.linkId = linkId;
// }
//
// /** DO NOT CALL, no longer implemented. Use {@link PerfMark#linkIn} instead. */
// @Deprecated
// @DoNotCall
// public void link() {}
// }
//
// Path: api/src/main/java/io/perfmark/StringFunction.java
// public interface StringFunction<T> {
//
// /**
// * Takes the given argument and produces a String.
// *
// * @since 0.22.0
// * @param t the subject to Stringify
// * @return the String
// */
// String apply(T t);
// }
//
// Path: api/src/main/java/io/perfmark/Tag.java
// public final class Tag {
// @Nullable final String tagName;
// final long tagId;
//
// Tag(@Nullable String tagName, long tagId) {
// // tagName should be non-null, but checking is expensive
// this.tagName = tagName;
// this.tagId = tagId;
// }
// }
| import io.perfmark.Impl;
import io.perfmark.Link;
import io.perfmark.StringFunction;
import io.perfmark.Tag;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import javax.annotation.Nullable; | /*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.impl;
final class SecretPerfMarkImpl {
public static final class PerfMarkImpl extends Impl { | // Path: api/src/main/java/io/perfmark/Impl.java
// public class Impl {
// static final String NO_TAG_NAME = "";
// static final long NO_TAG_ID = Long.MIN_VALUE;
// /**
// * This value is current {@link Long#MIN_VALUE}, but it could also be {@code 0}. The invariant
// * {@code NO_LINK_ID == -NO_LINK_ID} must be maintained to work when PerfMark is disabled.
// */
// private static final long NO_LINK_ID = Long.MIN_VALUE;
//
// static final Tag NO_TAG = new Tag(Impl.NO_TAG_NAME, Impl.NO_TAG_ID);
// static final Link NO_LINK = new Link(Impl.NO_LINK_ID);
//
// /** The Noop implementation */
// protected Impl(Tag key) {
// if (key != NO_TAG) {
// throw new AssertionError("nope");
// }
// }
//
// protected void setEnabled(boolean value) {}
//
// protected <T> void startTask(T taskNameObject, StringFunction<? super T> taskNameFunc) {}
//
// protected void startTask(String taskName, Tag tag) {}
//
// protected void startTask(String taskName) {}
//
// protected void startTask(String taskName, String subTaskName) {}
//
// protected void event(String eventName, Tag tag) {}
//
// protected void event(String eventName) {}
//
// protected void event(String eventName, String subEventName) {}
//
// protected void stopTask() {}
//
// protected void stopTask(String taskName, Tag tag) {}
//
// protected void stopTask(String taskName) {}
//
// protected void stopTask(String taskName, String subTaskName) {}
//
// protected Link linkOut() {
// return NO_LINK;
// }
//
// protected void linkIn(Link link) {}
//
// protected void attachTag(Tag tag) {}
//
// protected void attachTag(String tagName, String tagValue) {}
//
// protected void attachTag(String tagName, long tagValue) {}
//
// protected void attachTag(String tagName, long tagValue0, long tagValue1) {}
//
// protected <T> void attachTag(
// String tagName, T tagObject, StringFunction<? super T> stringFunction) {}
//
// protected Tag createTag(@Nullable String tagName, long tagId) {
// return NO_TAG;
// }
//
// @Nullable
// protected static String unpackTagName(Tag tag) {
// return tag.tagName;
// }
//
// protected static long unpackTagId(Tag tag) {
// return tag.tagId;
// }
//
// protected static long unpackLinkId(Link link) {
// return link.linkId;
// }
//
// protected static Tag packTag(@Nullable String tagName, long tagId) {
// return new Tag(tagName, tagId);
// }
//
// protected static Link packLink(long linkId) {
// return new Link(linkId);
// }
// }
//
// Path: api/src/main/java/io/perfmark/Link.java
// public final class Link {
//
// final long linkId;
//
// Link(long linkId) {
// this.linkId = linkId;
// }
//
// /** DO NOT CALL, no longer implemented. Use {@link PerfMark#linkIn} instead. */
// @Deprecated
// @DoNotCall
// public void link() {}
// }
//
// Path: api/src/main/java/io/perfmark/StringFunction.java
// public interface StringFunction<T> {
//
// /**
// * Takes the given argument and produces a String.
// *
// * @since 0.22.0
// * @param t the subject to Stringify
// * @return the String
// */
// String apply(T t);
// }
//
// Path: api/src/main/java/io/perfmark/Tag.java
// public final class Tag {
// @Nullable final String tagName;
// final long tagId;
//
// Tag(@Nullable String tagName, long tagId) {
// // tagName should be non-null, but checking is expensive
// this.tagName = tagName;
// this.tagId = tagId;
// }
// }
// Path: impl/src/main/java/io/perfmark/impl/SecretPerfMarkImpl.java
import io.perfmark.Impl;
import io.perfmark.Link;
import io.perfmark.StringFunction;
import io.perfmark.Tag;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import javax.annotation.Nullable;
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.impl;
final class SecretPerfMarkImpl {
public static final class PerfMarkImpl extends Impl { | private static final Tag NO_TAG = packTag(Mark.NO_TAG_NAME, Mark.NO_TAG_ID); |
perfmark/perfmark | impl/src/main/java/io/perfmark/impl/SecretPerfMarkImpl.java | // Path: api/src/main/java/io/perfmark/Impl.java
// public class Impl {
// static final String NO_TAG_NAME = "";
// static final long NO_TAG_ID = Long.MIN_VALUE;
// /**
// * This value is current {@link Long#MIN_VALUE}, but it could also be {@code 0}. The invariant
// * {@code NO_LINK_ID == -NO_LINK_ID} must be maintained to work when PerfMark is disabled.
// */
// private static final long NO_LINK_ID = Long.MIN_VALUE;
//
// static final Tag NO_TAG = new Tag(Impl.NO_TAG_NAME, Impl.NO_TAG_ID);
// static final Link NO_LINK = new Link(Impl.NO_LINK_ID);
//
// /** The Noop implementation */
// protected Impl(Tag key) {
// if (key != NO_TAG) {
// throw new AssertionError("nope");
// }
// }
//
// protected void setEnabled(boolean value) {}
//
// protected <T> void startTask(T taskNameObject, StringFunction<? super T> taskNameFunc) {}
//
// protected void startTask(String taskName, Tag tag) {}
//
// protected void startTask(String taskName) {}
//
// protected void startTask(String taskName, String subTaskName) {}
//
// protected void event(String eventName, Tag tag) {}
//
// protected void event(String eventName) {}
//
// protected void event(String eventName, String subEventName) {}
//
// protected void stopTask() {}
//
// protected void stopTask(String taskName, Tag tag) {}
//
// protected void stopTask(String taskName) {}
//
// protected void stopTask(String taskName, String subTaskName) {}
//
// protected Link linkOut() {
// return NO_LINK;
// }
//
// protected void linkIn(Link link) {}
//
// protected void attachTag(Tag tag) {}
//
// protected void attachTag(String tagName, String tagValue) {}
//
// protected void attachTag(String tagName, long tagValue) {}
//
// protected void attachTag(String tagName, long tagValue0, long tagValue1) {}
//
// protected <T> void attachTag(
// String tagName, T tagObject, StringFunction<? super T> stringFunction) {}
//
// protected Tag createTag(@Nullable String tagName, long tagId) {
// return NO_TAG;
// }
//
// @Nullable
// protected static String unpackTagName(Tag tag) {
// return tag.tagName;
// }
//
// protected static long unpackTagId(Tag tag) {
// return tag.tagId;
// }
//
// protected static long unpackLinkId(Link link) {
// return link.linkId;
// }
//
// protected static Tag packTag(@Nullable String tagName, long tagId) {
// return new Tag(tagName, tagId);
// }
//
// protected static Link packLink(long linkId) {
// return new Link(linkId);
// }
// }
//
// Path: api/src/main/java/io/perfmark/Link.java
// public final class Link {
//
// final long linkId;
//
// Link(long linkId) {
// this.linkId = linkId;
// }
//
// /** DO NOT CALL, no longer implemented. Use {@link PerfMark#linkIn} instead. */
// @Deprecated
// @DoNotCall
// public void link() {}
// }
//
// Path: api/src/main/java/io/perfmark/StringFunction.java
// public interface StringFunction<T> {
//
// /**
// * Takes the given argument and produces a String.
// *
// * @since 0.22.0
// * @param t the subject to Stringify
// * @return the String
// */
// String apply(T t);
// }
//
// Path: api/src/main/java/io/perfmark/Tag.java
// public final class Tag {
// @Nullable final String tagName;
// final long tagId;
//
// Tag(@Nullable String tagName, long tagId) {
// // tagName should be non-null, but checking is expensive
// this.tagName = tagName;
// this.tagId = tagId;
// }
// }
| import io.perfmark.Impl;
import io.perfmark.Link;
import io.perfmark.StringFunction;
import io.perfmark.Tag;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import javax.annotation.Nullable; | /*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.impl;
final class SecretPerfMarkImpl {
public static final class PerfMarkImpl extends Impl {
private static final Tag NO_TAG = packTag(Mark.NO_TAG_NAME, Mark.NO_TAG_ID); | // Path: api/src/main/java/io/perfmark/Impl.java
// public class Impl {
// static final String NO_TAG_NAME = "";
// static final long NO_TAG_ID = Long.MIN_VALUE;
// /**
// * This value is current {@link Long#MIN_VALUE}, but it could also be {@code 0}. The invariant
// * {@code NO_LINK_ID == -NO_LINK_ID} must be maintained to work when PerfMark is disabled.
// */
// private static final long NO_LINK_ID = Long.MIN_VALUE;
//
// static final Tag NO_TAG = new Tag(Impl.NO_TAG_NAME, Impl.NO_TAG_ID);
// static final Link NO_LINK = new Link(Impl.NO_LINK_ID);
//
// /** The Noop implementation */
// protected Impl(Tag key) {
// if (key != NO_TAG) {
// throw new AssertionError("nope");
// }
// }
//
// protected void setEnabled(boolean value) {}
//
// protected <T> void startTask(T taskNameObject, StringFunction<? super T> taskNameFunc) {}
//
// protected void startTask(String taskName, Tag tag) {}
//
// protected void startTask(String taskName) {}
//
// protected void startTask(String taskName, String subTaskName) {}
//
// protected void event(String eventName, Tag tag) {}
//
// protected void event(String eventName) {}
//
// protected void event(String eventName, String subEventName) {}
//
// protected void stopTask() {}
//
// protected void stopTask(String taskName, Tag tag) {}
//
// protected void stopTask(String taskName) {}
//
// protected void stopTask(String taskName, String subTaskName) {}
//
// protected Link linkOut() {
// return NO_LINK;
// }
//
// protected void linkIn(Link link) {}
//
// protected void attachTag(Tag tag) {}
//
// protected void attachTag(String tagName, String tagValue) {}
//
// protected void attachTag(String tagName, long tagValue) {}
//
// protected void attachTag(String tagName, long tagValue0, long tagValue1) {}
//
// protected <T> void attachTag(
// String tagName, T tagObject, StringFunction<? super T> stringFunction) {}
//
// protected Tag createTag(@Nullable String tagName, long tagId) {
// return NO_TAG;
// }
//
// @Nullable
// protected static String unpackTagName(Tag tag) {
// return tag.tagName;
// }
//
// protected static long unpackTagId(Tag tag) {
// return tag.tagId;
// }
//
// protected static long unpackLinkId(Link link) {
// return link.linkId;
// }
//
// protected static Tag packTag(@Nullable String tagName, long tagId) {
// return new Tag(tagName, tagId);
// }
//
// protected static Link packLink(long linkId) {
// return new Link(linkId);
// }
// }
//
// Path: api/src/main/java/io/perfmark/Link.java
// public final class Link {
//
// final long linkId;
//
// Link(long linkId) {
// this.linkId = linkId;
// }
//
// /** DO NOT CALL, no longer implemented. Use {@link PerfMark#linkIn} instead. */
// @Deprecated
// @DoNotCall
// public void link() {}
// }
//
// Path: api/src/main/java/io/perfmark/StringFunction.java
// public interface StringFunction<T> {
//
// /**
// * Takes the given argument and produces a String.
// *
// * @since 0.22.0
// * @param t the subject to Stringify
// * @return the String
// */
// String apply(T t);
// }
//
// Path: api/src/main/java/io/perfmark/Tag.java
// public final class Tag {
// @Nullable final String tagName;
// final long tagId;
//
// Tag(@Nullable String tagName, long tagId) {
// // tagName should be non-null, but checking is expensive
// this.tagName = tagName;
// this.tagId = tagId;
// }
// }
// Path: impl/src/main/java/io/perfmark/impl/SecretPerfMarkImpl.java
import io.perfmark.Impl;
import io.perfmark.Link;
import io.perfmark.StringFunction;
import io.perfmark.Tag;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import javax.annotation.Nullable;
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.impl;
final class SecretPerfMarkImpl {
public static final class PerfMarkImpl extends Impl {
private static final Tag NO_TAG = packTag(Mark.NO_TAG_NAME, Mark.NO_TAG_ID); | private static final Link NO_LINK = packLink(Mark.NO_LINK_ID); |
perfmark/perfmark | impl/src/main/java/io/perfmark/impl/SecretPerfMarkImpl.java | // Path: api/src/main/java/io/perfmark/Impl.java
// public class Impl {
// static final String NO_TAG_NAME = "";
// static final long NO_TAG_ID = Long.MIN_VALUE;
// /**
// * This value is current {@link Long#MIN_VALUE}, but it could also be {@code 0}. The invariant
// * {@code NO_LINK_ID == -NO_LINK_ID} must be maintained to work when PerfMark is disabled.
// */
// private static final long NO_LINK_ID = Long.MIN_VALUE;
//
// static final Tag NO_TAG = new Tag(Impl.NO_TAG_NAME, Impl.NO_TAG_ID);
// static final Link NO_LINK = new Link(Impl.NO_LINK_ID);
//
// /** The Noop implementation */
// protected Impl(Tag key) {
// if (key != NO_TAG) {
// throw new AssertionError("nope");
// }
// }
//
// protected void setEnabled(boolean value) {}
//
// protected <T> void startTask(T taskNameObject, StringFunction<? super T> taskNameFunc) {}
//
// protected void startTask(String taskName, Tag tag) {}
//
// protected void startTask(String taskName) {}
//
// protected void startTask(String taskName, String subTaskName) {}
//
// protected void event(String eventName, Tag tag) {}
//
// protected void event(String eventName) {}
//
// protected void event(String eventName, String subEventName) {}
//
// protected void stopTask() {}
//
// protected void stopTask(String taskName, Tag tag) {}
//
// protected void stopTask(String taskName) {}
//
// protected void stopTask(String taskName, String subTaskName) {}
//
// protected Link linkOut() {
// return NO_LINK;
// }
//
// protected void linkIn(Link link) {}
//
// protected void attachTag(Tag tag) {}
//
// protected void attachTag(String tagName, String tagValue) {}
//
// protected void attachTag(String tagName, long tagValue) {}
//
// protected void attachTag(String tagName, long tagValue0, long tagValue1) {}
//
// protected <T> void attachTag(
// String tagName, T tagObject, StringFunction<? super T> stringFunction) {}
//
// protected Tag createTag(@Nullable String tagName, long tagId) {
// return NO_TAG;
// }
//
// @Nullable
// protected static String unpackTagName(Tag tag) {
// return tag.tagName;
// }
//
// protected static long unpackTagId(Tag tag) {
// return tag.tagId;
// }
//
// protected static long unpackLinkId(Link link) {
// return link.linkId;
// }
//
// protected static Tag packTag(@Nullable String tagName, long tagId) {
// return new Tag(tagName, tagId);
// }
//
// protected static Link packLink(long linkId) {
// return new Link(linkId);
// }
// }
//
// Path: api/src/main/java/io/perfmark/Link.java
// public final class Link {
//
// final long linkId;
//
// Link(long linkId) {
// this.linkId = linkId;
// }
//
// /** DO NOT CALL, no longer implemented. Use {@link PerfMark#linkIn} instead. */
// @Deprecated
// @DoNotCall
// public void link() {}
// }
//
// Path: api/src/main/java/io/perfmark/StringFunction.java
// public interface StringFunction<T> {
//
// /**
// * Takes the given argument and produces a String.
// *
// * @since 0.22.0
// * @param t the subject to Stringify
// * @return the String
// */
// String apply(T t);
// }
//
// Path: api/src/main/java/io/perfmark/Tag.java
// public final class Tag {
// @Nullable final String tagName;
// final long tagId;
//
// Tag(@Nullable String tagName, long tagId) {
// // tagName should be non-null, but checking is expensive
// this.tagName = tagName;
// this.tagId = tagId;
// }
// }
| import io.perfmark.Impl;
import io.perfmark.Link;
import io.perfmark.StringFunction;
import io.perfmark.Tag;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import javax.annotation.Nullable; | }
@Override
protected void startTask(String taskName, Tag tag) {
final long gen = getGen();
if (!isEnabled(gen)) {
return;
}
Storage.startAnyway(gen, taskName, unpackTagName(tag), unpackTagId(tag));
}
@Override
protected void startTask(String taskName) {
final long gen = getGen();
if (!isEnabled(gen)) {
return;
}
Storage.startAnyway(gen, taskName);
}
@Override
protected void startTask(String taskName, String subTaskName) {
final long gen = getGen();
if (!isEnabled(gen)) {
return;
}
Storage.startAnyway(gen, taskName, subTaskName);
}
@Override | // Path: api/src/main/java/io/perfmark/Impl.java
// public class Impl {
// static final String NO_TAG_NAME = "";
// static final long NO_TAG_ID = Long.MIN_VALUE;
// /**
// * This value is current {@link Long#MIN_VALUE}, but it could also be {@code 0}. The invariant
// * {@code NO_LINK_ID == -NO_LINK_ID} must be maintained to work when PerfMark is disabled.
// */
// private static final long NO_LINK_ID = Long.MIN_VALUE;
//
// static final Tag NO_TAG = new Tag(Impl.NO_TAG_NAME, Impl.NO_TAG_ID);
// static final Link NO_LINK = new Link(Impl.NO_LINK_ID);
//
// /** The Noop implementation */
// protected Impl(Tag key) {
// if (key != NO_TAG) {
// throw new AssertionError("nope");
// }
// }
//
// protected void setEnabled(boolean value) {}
//
// protected <T> void startTask(T taskNameObject, StringFunction<? super T> taskNameFunc) {}
//
// protected void startTask(String taskName, Tag tag) {}
//
// protected void startTask(String taskName) {}
//
// protected void startTask(String taskName, String subTaskName) {}
//
// protected void event(String eventName, Tag tag) {}
//
// protected void event(String eventName) {}
//
// protected void event(String eventName, String subEventName) {}
//
// protected void stopTask() {}
//
// protected void stopTask(String taskName, Tag tag) {}
//
// protected void stopTask(String taskName) {}
//
// protected void stopTask(String taskName, String subTaskName) {}
//
// protected Link linkOut() {
// return NO_LINK;
// }
//
// protected void linkIn(Link link) {}
//
// protected void attachTag(Tag tag) {}
//
// protected void attachTag(String tagName, String tagValue) {}
//
// protected void attachTag(String tagName, long tagValue) {}
//
// protected void attachTag(String tagName, long tagValue0, long tagValue1) {}
//
// protected <T> void attachTag(
// String tagName, T tagObject, StringFunction<? super T> stringFunction) {}
//
// protected Tag createTag(@Nullable String tagName, long tagId) {
// return NO_TAG;
// }
//
// @Nullable
// protected static String unpackTagName(Tag tag) {
// return tag.tagName;
// }
//
// protected static long unpackTagId(Tag tag) {
// return tag.tagId;
// }
//
// protected static long unpackLinkId(Link link) {
// return link.linkId;
// }
//
// protected static Tag packTag(@Nullable String tagName, long tagId) {
// return new Tag(tagName, tagId);
// }
//
// protected static Link packLink(long linkId) {
// return new Link(linkId);
// }
// }
//
// Path: api/src/main/java/io/perfmark/Link.java
// public final class Link {
//
// final long linkId;
//
// Link(long linkId) {
// this.linkId = linkId;
// }
//
// /** DO NOT CALL, no longer implemented. Use {@link PerfMark#linkIn} instead. */
// @Deprecated
// @DoNotCall
// public void link() {}
// }
//
// Path: api/src/main/java/io/perfmark/StringFunction.java
// public interface StringFunction<T> {
//
// /**
// * Takes the given argument and produces a String.
// *
// * @since 0.22.0
// * @param t the subject to Stringify
// * @return the String
// */
// String apply(T t);
// }
//
// Path: api/src/main/java/io/perfmark/Tag.java
// public final class Tag {
// @Nullable final String tagName;
// final long tagId;
//
// Tag(@Nullable String tagName, long tagId) {
// // tagName should be non-null, but checking is expensive
// this.tagName = tagName;
// this.tagId = tagId;
// }
// }
// Path: impl/src/main/java/io/perfmark/impl/SecretPerfMarkImpl.java
import io.perfmark.Impl;
import io.perfmark.Link;
import io.perfmark.StringFunction;
import io.perfmark.Tag;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import javax.annotation.Nullable;
}
@Override
protected void startTask(String taskName, Tag tag) {
final long gen = getGen();
if (!isEnabled(gen)) {
return;
}
Storage.startAnyway(gen, taskName, unpackTagName(tag), unpackTagId(tag));
}
@Override
protected void startTask(String taskName) {
final long gen = getGen();
if (!isEnabled(gen)) {
return;
}
Storage.startAnyway(gen, taskName);
}
@Override
protected void startTask(String taskName, String subTaskName) {
final long gen = getGen();
if (!isEnabled(gen)) {
return;
}
Storage.startAnyway(gen, taskName, subTaskName);
}
@Override | protected <T> void startTask(T taskNameObject, StringFunction<? super T> stringFunction) { |
perfmark/perfmark | java15/src/main/java/io/perfmark/java15/SecretHiddenClassMarkHolderProvider.java | // Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
//
// public static final int NO_MAX_MARKS = -1;
//
// public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void start(long gen, String taskName, long nanoTime);
//
// public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void link(long gen, long linkId);
//
// public abstract void stop(long gen, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void stop(long gen, String taskName, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
//
// public abstract void event(long gen, String eventName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
//
// public abstract void attachTag(long gen, String tagName, long tagId);
//
// public abstract void attachKeyedTag(long gen, String name, String value);
//
// public abstract void attachKeyedTag(long gen, String name, long value0);
//
// public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
//
// public abstract void resetForTest();
//
// public abstract List<Mark> read(boolean concurrentWrites);
//
// public int maxMarks() {
// return NO_MAX_MARKS;
// }
//
// protected MarkHolder() {}
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolderProvider.java
// public abstract class MarkHolderProvider {
//
// protected MarkHolderProvider() {}
//
// /**
// * To be removed in 0.26.0
// *
// * @return the new MarkHolder for the current thread.
// */
// @Deprecated
// public MarkHolder create() {
// throw new UnsupportedOperationException();
// }
//
// /**
// * Creates a new MarkHolder. Mark holders are always mutated by the thread that created them, (e.g. THIS thread),
// * but may be read by other threads.
// *
// * @param markHolderId the Unique ID associated with the Mark Holder. This exists as a work around to Java's
// * thread ID, which does not guarantee they will not be reused.
// * @return the new MarkHolder for the current thread.
// * @since 0.24.0
// */
// public MarkHolder create(long markHolderId) {
// return create();
// }
// }
| import io.perfmark.impl.MarkHolder;
import io.perfmark.impl.MarkHolderProvider;
import java.io.IOException;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays; | /*
* Copyright 2021 Carl Mastrangelo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java15;
public final class SecretHiddenClassMarkHolderProvider {
public static final class HiddenClassMarkHolderProvider extends MarkHolderProvider {
private static final int DEFAULT_SIZE = 32768;
private final int[] maxEventsOffsets;
private final int[] maxEventsMaskOffsets;
private final byte[] markHolderClassData;
public HiddenClassMarkHolderProvider() {
try (InputStream classData = getClass().getResourceAsStream("HiddenClassVarHandleMarkHolder.class")) {
markHolderClassData = classData.readAllBytes();
} catch (IOException e) {
throw new RuntimeException(e);
}
ByteBuffer expectedMaxEvents = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN);
expectedMaxEvents.putInt(HiddenClassVarHandleMarkHolder.MAX_EVENTS);
byte[] maxEvents = expectedMaxEvents.array();
maxEventsOffsets = findOffsets(markHolderClassData, maxEvents);
if (maxEventsOffsets.length != 2) {
throw new RuntimeException("hop");
}
ByteBuffer expectedMaxEventsMask = ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN);
expectedMaxEventsMask.putLong(HiddenClassVarHandleMarkHolder.MAX_EVENTS_MASK);
byte[] maxEventsMax = expectedMaxEventsMask.array();
maxEventsMaskOffsets = findOffsets(markHolderClassData, maxEventsMax);
if (maxEventsMaskOffsets.length != 1) {
throw new RuntimeException("skip");
}
replaceSize(markHolderClassData, DEFAULT_SIZE);
}
@Override | // Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
//
// public static final int NO_MAX_MARKS = -1;
//
// public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void start(long gen, String taskName, long nanoTime);
//
// public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void link(long gen, long linkId);
//
// public abstract void stop(long gen, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void stop(long gen, String taskName, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
//
// public abstract void event(long gen, String eventName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
//
// public abstract void attachTag(long gen, String tagName, long tagId);
//
// public abstract void attachKeyedTag(long gen, String name, String value);
//
// public abstract void attachKeyedTag(long gen, String name, long value0);
//
// public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
//
// public abstract void resetForTest();
//
// public abstract List<Mark> read(boolean concurrentWrites);
//
// public int maxMarks() {
// return NO_MAX_MARKS;
// }
//
// protected MarkHolder() {}
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolderProvider.java
// public abstract class MarkHolderProvider {
//
// protected MarkHolderProvider() {}
//
// /**
// * To be removed in 0.26.0
// *
// * @return the new MarkHolder for the current thread.
// */
// @Deprecated
// public MarkHolder create() {
// throw new UnsupportedOperationException();
// }
//
// /**
// * Creates a new MarkHolder. Mark holders are always mutated by the thread that created them, (e.g. THIS thread),
// * but may be read by other threads.
// *
// * @param markHolderId the Unique ID associated with the Mark Holder. This exists as a work around to Java's
// * thread ID, which does not guarantee they will not be reused.
// * @return the new MarkHolder for the current thread.
// * @since 0.24.0
// */
// public MarkHolder create(long markHolderId) {
// return create();
// }
// }
// Path: java15/src/main/java/io/perfmark/java15/SecretHiddenClassMarkHolderProvider.java
import io.perfmark.impl.MarkHolder;
import io.perfmark.impl.MarkHolderProvider;
import java.io.IOException;
import java.io.InputStream;
import java.lang.invoke.MethodHandles;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Arrays;
/*
* Copyright 2021 Carl Mastrangelo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java15;
public final class SecretHiddenClassMarkHolderProvider {
public static final class HiddenClassMarkHolderProvider extends MarkHolderProvider {
private static final int DEFAULT_SIZE = 32768;
private final int[] maxEventsOffsets;
private final int[] maxEventsMaskOffsets;
private final byte[] markHolderClassData;
public HiddenClassMarkHolderProvider() {
try (InputStream classData = getClass().getResourceAsStream("HiddenClassVarHandleMarkHolder.class")) {
markHolderClassData = classData.readAllBytes();
} catch (IOException e) {
throw new RuntimeException(e);
}
ByteBuffer expectedMaxEvents = ByteBuffer.allocate(4).order(ByteOrder.BIG_ENDIAN);
expectedMaxEvents.putInt(HiddenClassVarHandleMarkHolder.MAX_EVENTS);
byte[] maxEvents = expectedMaxEvents.array();
maxEventsOffsets = findOffsets(markHolderClassData, maxEvents);
if (maxEventsOffsets.length != 2) {
throw new RuntimeException("hop");
}
ByteBuffer expectedMaxEventsMask = ByteBuffer.allocate(8).order(ByteOrder.BIG_ENDIAN);
expectedMaxEventsMask.putLong(HiddenClassVarHandleMarkHolder.MAX_EVENTS_MASK);
byte[] maxEventsMax = expectedMaxEventsMask.array();
maxEventsMaskOffsets = findOffsets(markHolderClassData, maxEventsMax);
if (maxEventsMaskOffsets.length != 1) {
throw new RuntimeException("skip");
}
replaceSize(markHolderClassData, DEFAULT_SIZE);
}
@Override | public MarkHolder create(long markHolderId) { |
perfmark/perfmark | java9/src/main/java/io/perfmark/java9/SecretVarHandleMarkHolderProvider.java | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
//
// public static final int NO_MAX_MARKS = -1;
//
// public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void start(long gen, String taskName, long nanoTime);
//
// public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void link(long gen, long linkId);
//
// public abstract void stop(long gen, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void stop(long gen, String taskName, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
//
// public abstract void event(long gen, String eventName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
//
// public abstract void attachTag(long gen, String tagName, long tagId);
//
// public abstract void attachKeyedTag(long gen, String name, String value);
//
// public abstract void attachKeyedTag(long gen, String name, long value0);
//
// public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
//
// public abstract void resetForTest();
//
// public abstract List<Mark> read(boolean concurrentWrites);
//
// public int maxMarks() {
// return NO_MAX_MARKS;
// }
//
// protected MarkHolder() {}
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolderProvider.java
// public abstract class MarkHolderProvider {
//
// protected MarkHolderProvider() {}
//
// /**
// * To be removed in 0.26.0
// *
// * @return the new MarkHolder for the current thread.
// */
// @Deprecated
// public MarkHolder create() {
// throw new UnsupportedOperationException();
// }
//
// /**
// * Creates a new MarkHolder. Mark holders are always mutated by the thread that created them, (e.g. THIS thread),
// * but may be read by other threads.
// *
// * @param markHolderId the Unique ID associated with the Mark Holder. This exists as a work around to Java's
// * thread ID, which does not guarantee they will not be reused.
// * @return the new MarkHolder for the current thread.
// * @since 0.24.0
// */
// public MarkHolder create(long markHolderId) {
// return create();
// }
// }
| import io.perfmark.impl.Generator;
import io.perfmark.impl.MarkHolder;
import io.perfmark.impl.MarkHolderProvider; | /*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java9;
final class SecretVarHandleMarkHolderProvider {
public static final class VarHandleMarkHolderProvider extends MarkHolderProvider {
public VarHandleMarkHolderProvider() {
// Do some basic operations to see if it works. | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
//
// public static final int NO_MAX_MARKS = -1;
//
// public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void start(long gen, String taskName, long nanoTime);
//
// public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void link(long gen, long linkId);
//
// public abstract void stop(long gen, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void stop(long gen, String taskName, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
//
// public abstract void event(long gen, String eventName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
//
// public abstract void attachTag(long gen, String tagName, long tagId);
//
// public abstract void attachKeyedTag(long gen, String name, String value);
//
// public abstract void attachKeyedTag(long gen, String name, long value0);
//
// public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
//
// public abstract void resetForTest();
//
// public abstract List<Mark> read(boolean concurrentWrites);
//
// public int maxMarks() {
// return NO_MAX_MARKS;
// }
//
// protected MarkHolder() {}
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolderProvider.java
// public abstract class MarkHolderProvider {
//
// protected MarkHolderProvider() {}
//
// /**
// * To be removed in 0.26.0
// *
// * @return the new MarkHolder for the current thread.
// */
// @Deprecated
// public MarkHolder create() {
// throw new UnsupportedOperationException();
// }
//
// /**
// * Creates a new MarkHolder. Mark holders are always mutated by the thread that created them, (e.g. THIS thread),
// * but may be read by other threads.
// *
// * @param markHolderId the Unique ID associated with the Mark Holder. This exists as a work around to Java's
// * thread ID, which does not guarantee they will not be reused.
// * @return the new MarkHolder for the current thread.
// * @since 0.24.0
// */
// public MarkHolder create(long markHolderId) {
// return create();
// }
// }
// Path: java9/src/main/java/io/perfmark/java9/SecretVarHandleMarkHolderProvider.java
import io.perfmark.impl.Generator;
import io.perfmark.impl.MarkHolder;
import io.perfmark.impl.MarkHolderProvider;
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java9;
final class SecretVarHandleMarkHolderProvider {
public static final class VarHandleMarkHolderProvider extends MarkHolderProvider {
public VarHandleMarkHolderProvider() {
// Do some basic operations to see if it works. | MarkHolder holder = create(12345); |
perfmark/perfmark | java9/src/main/java/io/perfmark/java9/SecretVarHandleMarkHolderProvider.java | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
//
// public static final int NO_MAX_MARKS = -1;
//
// public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void start(long gen, String taskName, long nanoTime);
//
// public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void link(long gen, long linkId);
//
// public abstract void stop(long gen, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void stop(long gen, String taskName, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
//
// public abstract void event(long gen, String eventName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
//
// public abstract void attachTag(long gen, String tagName, long tagId);
//
// public abstract void attachKeyedTag(long gen, String name, String value);
//
// public abstract void attachKeyedTag(long gen, String name, long value0);
//
// public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
//
// public abstract void resetForTest();
//
// public abstract List<Mark> read(boolean concurrentWrites);
//
// public int maxMarks() {
// return NO_MAX_MARKS;
// }
//
// protected MarkHolder() {}
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolderProvider.java
// public abstract class MarkHolderProvider {
//
// protected MarkHolderProvider() {}
//
// /**
// * To be removed in 0.26.0
// *
// * @return the new MarkHolder for the current thread.
// */
// @Deprecated
// public MarkHolder create() {
// throw new UnsupportedOperationException();
// }
//
// /**
// * Creates a new MarkHolder. Mark holders are always mutated by the thread that created them, (e.g. THIS thread),
// * but may be read by other threads.
// *
// * @param markHolderId the Unique ID associated with the Mark Holder. This exists as a work around to Java's
// * thread ID, which does not guarantee they will not be reused.
// * @return the new MarkHolder for the current thread.
// * @since 0.24.0
// */
// public MarkHolder create(long markHolderId) {
// return create();
// }
// }
| import io.perfmark.impl.Generator;
import io.perfmark.impl.MarkHolder;
import io.perfmark.impl.MarkHolderProvider; | /*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java9;
final class SecretVarHandleMarkHolderProvider {
public static final class VarHandleMarkHolderProvider extends MarkHolderProvider {
public VarHandleMarkHolderProvider() {
// Do some basic operations to see if it works.
MarkHolder holder = create(12345); | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
//
// public static final int NO_MAX_MARKS = -1;
//
// public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void start(long gen, String taskName, long nanoTime);
//
// public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void link(long gen, long linkId);
//
// public abstract void stop(long gen, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void stop(long gen, String taskName, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
//
// public abstract void event(long gen, String eventName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
//
// public abstract void attachTag(long gen, String tagName, long tagId);
//
// public abstract void attachKeyedTag(long gen, String name, String value);
//
// public abstract void attachKeyedTag(long gen, String name, long value0);
//
// public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
//
// public abstract void resetForTest();
//
// public abstract List<Mark> read(boolean concurrentWrites);
//
// public int maxMarks() {
// return NO_MAX_MARKS;
// }
//
// protected MarkHolder() {}
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolderProvider.java
// public abstract class MarkHolderProvider {
//
// protected MarkHolderProvider() {}
//
// /**
// * To be removed in 0.26.0
// *
// * @return the new MarkHolder for the current thread.
// */
// @Deprecated
// public MarkHolder create() {
// throw new UnsupportedOperationException();
// }
//
// /**
// * Creates a new MarkHolder. Mark holders are always mutated by the thread that created them, (e.g. THIS thread),
// * but may be read by other threads.
// *
// * @param markHolderId the Unique ID associated with the Mark Holder. This exists as a work around to Java's
// * thread ID, which does not guarantee they will not be reused.
// * @return the new MarkHolder for the current thread.
// * @since 0.24.0
// */
// public MarkHolder create(long markHolderId) {
// return create();
// }
// }
// Path: java9/src/main/java/io/perfmark/java9/SecretVarHandleMarkHolderProvider.java
import io.perfmark.impl.Generator;
import io.perfmark.impl.MarkHolder;
import io.perfmark.impl.MarkHolderProvider;
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java9;
final class SecretVarHandleMarkHolderProvider {
public static final class VarHandleMarkHolderProvider extends MarkHolderProvider {
public VarHandleMarkHolderProvider() {
// Do some basic operations to see if it works.
MarkHolder holder = create(12345); | holder.start(1 << Generator.GEN_OFFSET, "bogus", 0); |
perfmark/perfmark | java7/src/jmh/java/io/perfmark/java7/MethodHandleGeneratorBenchmarkTest.java | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: testing/src/main/java/io/perfmark/testing/GeneratorBenchmark.java
// @State(Scope.Benchmark)
// public class GeneratorBenchmark {
//
// private Generator generator;
//
// @Setup(Level.Trial)
// public void setUp() {
// generator = getGenerator();
// generator.setGeneration(Generator.FAILURE);
// }
//
// protected Generator getGenerator() {
// throw new UnsupportedOperationException();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public void ifEnabled() {
// if (isEnabled(getGeneration())) {
// Blackhole.consumeCPU(1000);
// }
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getGeneration() {
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// @GroupThreads(3)
// public long racyGetAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// protected static boolean isEnabled(long gen) {
// return ((gen >>> Generator.GEN_OFFSET) & 0x1L) != 0L;
// }
// }
| import io.perfmark.impl.Generator;
import io.perfmark.testing.GeneratorBenchmark;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.TimeValue;
import org.openjdk.jmh.runner.options.VerboseMode; | /*
* Copyright 2021 Carl Mastrangelo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java7;
@RunWith(JUnit4.class)
public class MethodHandleGeneratorBenchmarkTest {
@Test
public void generatorBenchmark() throws Exception {
Options options = new OptionsBuilder()
.include(MethodHandleGeneratorBenchmark.class.getCanonicalName())
.measurementIterations(5)
.warmupIterations(10)
.forks(1)
.verbosity(VerboseMode.EXTRA)
.warmupTime(TimeValue.seconds(1))
.measurementTime(TimeValue.seconds(1))
.shouldFailOnError(true)
// This is necessary to run in the IDE, otherwise it would inherit the VM args.
.jvmArgs("-da")
.build();
new Runner(options).run();
}
@State(Scope.Benchmark) | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: testing/src/main/java/io/perfmark/testing/GeneratorBenchmark.java
// @State(Scope.Benchmark)
// public class GeneratorBenchmark {
//
// private Generator generator;
//
// @Setup(Level.Trial)
// public void setUp() {
// generator = getGenerator();
// generator.setGeneration(Generator.FAILURE);
// }
//
// protected Generator getGenerator() {
// throw new UnsupportedOperationException();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public void ifEnabled() {
// if (isEnabled(getGeneration())) {
// Blackhole.consumeCPU(1000);
// }
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getGeneration() {
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// @GroupThreads(3)
// public long racyGetAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// protected static boolean isEnabled(long gen) {
// return ((gen >>> Generator.GEN_OFFSET) & 0x1L) != 0L;
// }
// }
// Path: java7/src/jmh/java/io/perfmark/java7/MethodHandleGeneratorBenchmarkTest.java
import io.perfmark.impl.Generator;
import io.perfmark.testing.GeneratorBenchmark;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.TimeValue;
import org.openjdk.jmh.runner.options.VerboseMode;
/*
* Copyright 2021 Carl Mastrangelo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java7;
@RunWith(JUnit4.class)
public class MethodHandleGeneratorBenchmarkTest {
@Test
public void generatorBenchmark() throws Exception {
Options options = new OptionsBuilder()
.include(MethodHandleGeneratorBenchmark.class.getCanonicalName())
.measurementIterations(5)
.warmupIterations(10)
.forks(1)
.verbosity(VerboseMode.EXTRA)
.warmupTime(TimeValue.seconds(1))
.measurementTime(TimeValue.seconds(1))
.shouldFailOnError(true)
// This is necessary to run in the IDE, otherwise it would inherit the VM args.
.jvmArgs("-da")
.build();
new Runner(options).run();
}
@State(Scope.Benchmark) | public static class MethodHandleGeneratorBenchmark extends GeneratorBenchmark { |
perfmark/perfmark | java7/src/jmh/java/io/perfmark/java7/MethodHandleGeneratorBenchmarkTest.java | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: testing/src/main/java/io/perfmark/testing/GeneratorBenchmark.java
// @State(Scope.Benchmark)
// public class GeneratorBenchmark {
//
// private Generator generator;
//
// @Setup(Level.Trial)
// public void setUp() {
// generator = getGenerator();
// generator.setGeneration(Generator.FAILURE);
// }
//
// protected Generator getGenerator() {
// throw new UnsupportedOperationException();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public void ifEnabled() {
// if (isEnabled(getGeneration())) {
// Blackhole.consumeCPU(1000);
// }
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getGeneration() {
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// @GroupThreads(3)
// public long racyGetAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// protected static boolean isEnabled(long gen) {
// return ((gen >>> Generator.GEN_OFFSET) & 0x1L) != 0L;
// }
// }
| import io.perfmark.impl.Generator;
import io.perfmark.testing.GeneratorBenchmark;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.TimeValue;
import org.openjdk.jmh.runner.options.VerboseMode; | /*
* Copyright 2021 Carl Mastrangelo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java7;
@RunWith(JUnit4.class)
public class MethodHandleGeneratorBenchmarkTest {
@Test
public void generatorBenchmark() throws Exception {
Options options = new OptionsBuilder()
.include(MethodHandleGeneratorBenchmark.class.getCanonicalName())
.measurementIterations(5)
.warmupIterations(10)
.forks(1)
.verbosity(VerboseMode.EXTRA)
.warmupTime(TimeValue.seconds(1))
.measurementTime(TimeValue.seconds(1))
.shouldFailOnError(true)
// This is necessary to run in the IDE, otherwise it would inherit the VM args.
.jvmArgs("-da")
.build();
new Runner(options).run();
}
@State(Scope.Benchmark)
public static class MethodHandleGeneratorBenchmark extends GeneratorBenchmark {
@Override | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: testing/src/main/java/io/perfmark/testing/GeneratorBenchmark.java
// @State(Scope.Benchmark)
// public class GeneratorBenchmark {
//
// private Generator generator;
//
// @Setup(Level.Trial)
// public void setUp() {
// generator = getGenerator();
// generator.setGeneration(Generator.FAILURE);
// }
//
// protected Generator getGenerator() {
// throw new UnsupportedOperationException();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public void ifEnabled() {
// if (isEnabled(getGeneration())) {
// Blackhole.consumeCPU(1000);
// }
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getGeneration() {
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// @GroupThreads(3)
// public long racyGetAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// protected static boolean isEnabled(long gen) {
// return ((gen >>> Generator.GEN_OFFSET) & 0x1L) != 0L;
// }
// }
// Path: java7/src/jmh/java/io/perfmark/java7/MethodHandleGeneratorBenchmarkTest.java
import io.perfmark.impl.Generator;
import io.perfmark.testing.GeneratorBenchmark;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.TimeValue;
import org.openjdk.jmh.runner.options.VerboseMode;
/*
* Copyright 2021 Carl Mastrangelo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java7;
@RunWith(JUnit4.class)
public class MethodHandleGeneratorBenchmarkTest {
@Test
public void generatorBenchmark() throws Exception {
Options options = new OptionsBuilder()
.include(MethodHandleGeneratorBenchmark.class.getCanonicalName())
.measurementIterations(5)
.warmupIterations(10)
.forks(1)
.verbosity(VerboseMode.EXTRA)
.warmupTime(TimeValue.seconds(1))
.measurementTime(TimeValue.seconds(1))
.shouldFailOnError(true)
// This is necessary to run in the IDE, otherwise it would inherit the VM args.
.jvmArgs("-da")
.build();
new Runner(options).run();
}
@State(Scope.Benchmark)
public static class MethodHandleGeneratorBenchmark extends GeneratorBenchmark {
@Override | protected Generator getGenerator() { |
perfmark/perfmark | java6/src/jmh/java/io/perfmark/java6/VolatileGeneratorBenchmarkTest.java | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: testing/src/main/java/io/perfmark/testing/GeneratorBenchmark.java
// @State(Scope.Benchmark)
// public class GeneratorBenchmark {
//
// private Generator generator;
//
// @Setup(Level.Trial)
// public void setUp() {
// generator = getGenerator();
// generator.setGeneration(Generator.FAILURE);
// }
//
// protected Generator getGenerator() {
// throw new UnsupportedOperationException();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public void ifEnabled() {
// if (isEnabled(getGeneration())) {
// Blackhole.consumeCPU(1000);
// }
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getGeneration() {
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// @GroupThreads(3)
// public long racyGetAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// protected static boolean isEnabled(long gen) {
// return ((gen >>> Generator.GEN_OFFSET) & 0x1L) != 0L;
// }
// }
| import io.perfmark.impl.Generator;
import io.perfmark.testing.GeneratorBenchmark;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.TimeValue; | /*
* Copyright 2021 Carl Mastrangelo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java6;
@RunWith(JUnit4.class)
public class VolatileGeneratorBenchmarkTest {
@Test
public void generatorBenchmark() throws Exception {
Options options = new OptionsBuilder()
.include(VolatileGeneratorBenchmark.class.getCanonicalName())
.measurementIterations(5)
.warmupIterations(10)
.forks(1)
.warmupTime(TimeValue.seconds(1))
.measurementTime(TimeValue.seconds(1))
.shouldFailOnError(true)
// This is necessary to run in the IDE, otherwise it would inherit the VM args.
.jvmArgs("-da")
.build();
new Runner(options).run();
}
@State(Scope.Benchmark) | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: testing/src/main/java/io/perfmark/testing/GeneratorBenchmark.java
// @State(Scope.Benchmark)
// public class GeneratorBenchmark {
//
// private Generator generator;
//
// @Setup(Level.Trial)
// public void setUp() {
// generator = getGenerator();
// generator.setGeneration(Generator.FAILURE);
// }
//
// protected Generator getGenerator() {
// throw new UnsupportedOperationException();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public void ifEnabled() {
// if (isEnabled(getGeneration())) {
// Blackhole.consumeCPU(1000);
// }
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getGeneration() {
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// @GroupThreads(3)
// public long racyGetAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// protected static boolean isEnabled(long gen) {
// return ((gen >>> Generator.GEN_OFFSET) & 0x1L) != 0L;
// }
// }
// Path: java6/src/jmh/java/io/perfmark/java6/VolatileGeneratorBenchmarkTest.java
import io.perfmark.impl.Generator;
import io.perfmark.testing.GeneratorBenchmark;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.TimeValue;
/*
* Copyright 2021 Carl Mastrangelo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java6;
@RunWith(JUnit4.class)
public class VolatileGeneratorBenchmarkTest {
@Test
public void generatorBenchmark() throws Exception {
Options options = new OptionsBuilder()
.include(VolatileGeneratorBenchmark.class.getCanonicalName())
.measurementIterations(5)
.warmupIterations(10)
.forks(1)
.warmupTime(TimeValue.seconds(1))
.measurementTime(TimeValue.seconds(1))
.shouldFailOnError(true)
// This is necessary to run in the IDE, otherwise it would inherit the VM args.
.jvmArgs("-da")
.build();
new Runner(options).run();
}
@State(Scope.Benchmark) | public static class VolatileGeneratorBenchmark extends GeneratorBenchmark { |
perfmark/perfmark | java6/src/jmh/java/io/perfmark/java6/VolatileGeneratorBenchmarkTest.java | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: testing/src/main/java/io/perfmark/testing/GeneratorBenchmark.java
// @State(Scope.Benchmark)
// public class GeneratorBenchmark {
//
// private Generator generator;
//
// @Setup(Level.Trial)
// public void setUp() {
// generator = getGenerator();
// generator.setGeneration(Generator.FAILURE);
// }
//
// protected Generator getGenerator() {
// throw new UnsupportedOperationException();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public void ifEnabled() {
// if (isEnabled(getGeneration())) {
// Blackhole.consumeCPU(1000);
// }
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getGeneration() {
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// @GroupThreads(3)
// public long racyGetAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// protected static boolean isEnabled(long gen) {
// return ((gen >>> Generator.GEN_OFFSET) & 0x1L) != 0L;
// }
// }
| import io.perfmark.impl.Generator;
import io.perfmark.testing.GeneratorBenchmark;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.TimeValue; | /*
* Copyright 2021 Carl Mastrangelo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java6;
@RunWith(JUnit4.class)
public class VolatileGeneratorBenchmarkTest {
@Test
public void generatorBenchmark() throws Exception {
Options options = new OptionsBuilder()
.include(VolatileGeneratorBenchmark.class.getCanonicalName())
.measurementIterations(5)
.warmupIterations(10)
.forks(1)
.warmupTime(TimeValue.seconds(1))
.measurementTime(TimeValue.seconds(1))
.shouldFailOnError(true)
// This is necessary to run in the IDE, otherwise it would inherit the VM args.
.jvmArgs("-da")
.build();
new Runner(options).run();
}
@State(Scope.Benchmark)
public static class VolatileGeneratorBenchmark extends GeneratorBenchmark {
@Override | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: testing/src/main/java/io/perfmark/testing/GeneratorBenchmark.java
// @State(Scope.Benchmark)
// public class GeneratorBenchmark {
//
// private Generator generator;
//
// @Setup(Level.Trial)
// public void setUp() {
// generator = getGenerator();
// generator.setGeneration(Generator.FAILURE);
// }
//
// protected Generator getGenerator() {
// throw new UnsupportedOperationException();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public void ifEnabled() {
// if (isEnabled(getGeneration())) {
// Blackhole.consumeCPU(1000);
// }
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getGeneration() {
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// public long getAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// @Benchmark
// @BenchmarkMode(Mode.AverageTime)
// @OutputTimeUnit(TimeUnit.NANOSECONDS)
// @GroupThreads(3)
// public long racyGetAndSetAndGetGeneration() {
// long oldGeneration = generator.getGeneration();
// generator.setGeneration(oldGeneration + 1);
// return generator.getGeneration();
// }
//
// protected static boolean isEnabled(long gen) {
// return ((gen >>> Generator.GEN_OFFSET) & 0x1L) != 0L;
// }
// }
// Path: java6/src/jmh/java/io/perfmark/java6/VolatileGeneratorBenchmarkTest.java
import io.perfmark.impl.Generator;
import io.perfmark.testing.GeneratorBenchmark;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import org.openjdk.jmh.runner.options.TimeValue;
/*
* Copyright 2021 Carl Mastrangelo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.java6;
@RunWith(JUnit4.class)
public class VolatileGeneratorBenchmarkTest {
@Test
public void generatorBenchmark() throws Exception {
Options options = new OptionsBuilder()
.include(VolatileGeneratorBenchmark.class.getCanonicalName())
.measurementIterations(5)
.warmupIterations(10)
.forks(1)
.warmupTime(TimeValue.seconds(1))
.measurementTime(TimeValue.seconds(1))
.shouldFailOnError(true)
// This is necessary to run in the IDE, otherwise it would inherit the VM args.
.jvmArgs("-da")
.build();
new Runner(options).run();
}
@State(Scope.Benchmark)
public static class VolatileGeneratorBenchmark extends GeneratorBenchmark {
@Override | protected Generator getGenerator() { |
perfmark/perfmark | testing/src/main/java/io/perfmark/testing/GeneratorBenchmark.java | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
| import io.perfmark.impl.Generator;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.GroupThreads;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole; | /*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.testing;
@State(Scope.Benchmark)
public class GeneratorBenchmark {
| // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
// Path: testing/src/main/java/io/perfmark/testing/GeneratorBenchmark.java
import io.perfmark.impl.Generator;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.GroupThreads;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.infra.Blackhole;
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.testing;
@State(Scope.Benchmark)
public class GeneratorBenchmark {
| private Generator generator; |
perfmark/perfmark | testing/src/main/java/io/perfmark/testing/MarkHolderBenchmark.java | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
//
// public static final int NO_MAX_MARKS = -1;
//
// public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void start(long gen, String taskName, long nanoTime);
//
// public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void link(long gen, long linkId);
//
// public abstract void stop(long gen, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void stop(long gen, String taskName, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
//
// public abstract void event(long gen, String eventName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
//
// public abstract void attachTag(long gen, String tagName, long tagId);
//
// public abstract void attachKeyedTag(long gen, String name, String value);
//
// public abstract void attachKeyedTag(long gen, String name, long value0);
//
// public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
//
// public abstract void resetForTest();
//
// public abstract List<Mark> read(boolean concurrentWrites);
//
// public int maxMarks() {
// return NO_MAX_MARKS;
// }
//
// protected MarkHolder() {}
// }
| import io.perfmark.impl.Generator;
import io.perfmark.impl.MarkHolder;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State; | /*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.testing;
@State(Scope.Thread)
public class MarkHolderBenchmark {
| // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
//
// public static final int NO_MAX_MARKS = -1;
//
// public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void start(long gen, String taskName, long nanoTime);
//
// public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void link(long gen, long linkId);
//
// public abstract void stop(long gen, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void stop(long gen, String taskName, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
//
// public abstract void event(long gen, String eventName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
//
// public abstract void attachTag(long gen, String tagName, long tagId);
//
// public abstract void attachKeyedTag(long gen, String name, String value);
//
// public abstract void attachKeyedTag(long gen, String name, long value0);
//
// public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
//
// public abstract void resetForTest();
//
// public abstract List<Mark> read(boolean concurrentWrites);
//
// public int maxMarks() {
// return NO_MAX_MARKS;
// }
//
// protected MarkHolder() {}
// }
// Path: testing/src/main/java/io/perfmark/testing/MarkHolderBenchmark.java
import io.perfmark.impl.Generator;
import io.perfmark.impl.MarkHolder;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.testing;
@State(Scope.Thread)
public class MarkHolderBenchmark {
| private static final long gen = 1 << Generator.GEN_OFFSET; |
perfmark/perfmark | testing/src/main/java/io/perfmark/testing/MarkHolderBenchmark.java | // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
//
// public static final int NO_MAX_MARKS = -1;
//
// public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void start(long gen, String taskName, long nanoTime);
//
// public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void link(long gen, long linkId);
//
// public abstract void stop(long gen, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void stop(long gen, String taskName, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
//
// public abstract void event(long gen, String eventName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
//
// public abstract void attachTag(long gen, String tagName, long tagId);
//
// public abstract void attachKeyedTag(long gen, String name, String value);
//
// public abstract void attachKeyedTag(long gen, String name, long value0);
//
// public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
//
// public abstract void resetForTest();
//
// public abstract List<Mark> read(boolean concurrentWrites);
//
// public int maxMarks() {
// return NO_MAX_MARKS;
// }
//
// protected MarkHolder() {}
// }
| import io.perfmark.impl.Generator;
import io.perfmark.impl.MarkHolder;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State; | /*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.testing;
@State(Scope.Thread)
public class MarkHolderBenchmark {
private static final long gen = 1 << Generator.GEN_OFFSET;
private static final String taskName = "hiya";
public static final List<String> ASM_FLAGS = List.of(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+LogCompilation",
"-XX:LogFile=/tmp/blah.txt",
"-XX:+PrintAssembly",
"-XX:+PrintInterpreter",
"-XX:+PrintNMethods",
"-XX:+PrintNativeNMethods",
"-XX:+PrintSignatureHandlers",
"-XX:+PrintAdapterHandlers",
"-XX:+PrintStubCode",
"-XX:+PrintCompilation",
"-XX:+PrintInlining",
"-XX:PrintAssemblyOptions=syntax",
"-XX:PrintAssemblyOptions=intel");
| // Path: impl/src/main/java/io/perfmark/impl/Generator.java
// @NotThreadSafe
// public abstract class Generator {
// /**
// * This field is here as a hack. This class is a shared dependency of both {@link
// * SecretPerfMarkImpl} and {@link Storage}. The impl needs to record the first time an event
// * occurs, but doesn't call Storage#clinit until PerfMark is enabled. This leads to the timings
// * being off in the trace event viewer, since the "start" time is since it was enabled, rather
// * than when the first PerfMark call happens.
// */
// static final long INIT_NANO_TIME = System.nanoTime();
//
// /**
// * The number of reserved bits at the bottom of the generation. All generations should be
// * left-shifted by this amount.
// */
// public static final int GEN_OFFSET = 8;
// /**
// * Represents a failure to enable PerfMark library. This can be used by subclasses to indicate a
// * previous failure to set the generation. It can also be used to indicate the generation count
// * has overflowed.
// */
// public static final long FAILURE = -2L << GEN_OFFSET;
//
// protected Generator() {}
//
// /**
// * Sets the current generation count. This should be eventually noticeable for callers of {@link
// * #getGeneration()}. An odd number means the library is enabled, while an even number means the
// * library is disabled.
// *
// * @param generation the generation id, shifted left by {@link #GEN_OFFSET}.
// */
// public abstract void setGeneration(long generation);
//
// /**
// * Gets the current generation, shifted left by {@link #GEN_OFFSET}. An odd number means the
// * library is enabled, while an even number means the library is disabled.
// *
// * @return the current generation or {@link #FAILURE}.
// */
// public abstract long getGeneration();
//
// /**
// * Returns the approximate cost to change the generation.
// *
// * @return an approximate number of nanoseconds needed to change the generator value.
// */
// public long costOfSetNanos() {
// return 1000000;
// }
//
// /**
// * Returns the approximate cost to read the generation.
// *
// * @return an approximate number of nanoseconds needed to read the generator value.
// */
// public long costOfGetNanos() {
// return 10;
// }
// }
//
// Path: impl/src/main/java/io/perfmark/impl/MarkHolder.java
// public abstract class MarkHolder {
//
// public static final int NO_MAX_MARKS = -1;
//
// public abstract void start(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void start(long gen, String taskName, long nanoTime);
//
// public abstract void start(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void link(long gen, long linkId);
//
// public abstract void stop(long gen, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String tagName, long tagId, long nanoTime);
//
// public abstract void stop(long gen, String taskName, long nanoTime);
//
// public abstract void stop(long gen, String taskName, String subTaskName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String tagName, long tagId, long nanoTime);
//
// public abstract void event(long gen, String eventName, long nanoTime);
//
// public abstract void event(long gen, String eventName, String subEventName, long nanoTime);
//
// public abstract void attachTag(long gen, String tagName, long tagId);
//
// public abstract void attachKeyedTag(long gen, String name, String value);
//
// public abstract void attachKeyedTag(long gen, String name, long value0);
//
// public abstract void attachKeyedTag(long gen, String name, long value0, long value1);
//
// public abstract void resetForTest();
//
// public abstract List<Mark> read(boolean concurrentWrites);
//
// public int maxMarks() {
// return NO_MAX_MARKS;
// }
//
// protected MarkHolder() {}
// }
// Path: testing/src/main/java/io/perfmark/testing/MarkHolderBenchmark.java
import io.perfmark.impl.Generator;
import io.perfmark.impl.MarkHolder;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
/*
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.perfmark.testing;
@State(Scope.Thread)
public class MarkHolderBenchmark {
private static final long gen = 1 << Generator.GEN_OFFSET;
private static final String taskName = "hiya";
public static final List<String> ASM_FLAGS = List.of(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+LogCompilation",
"-XX:LogFile=/tmp/blah.txt",
"-XX:+PrintAssembly",
"-XX:+PrintInterpreter",
"-XX:+PrintNMethods",
"-XX:+PrintNativeNMethods",
"-XX:+PrintSignatureHandlers",
"-XX:+PrintAdapterHandlers",
"-XX:+PrintStubCode",
"-XX:+PrintCompilation",
"-XX:+PrintInlining",
"-XX:PrintAssemblyOptions=syntax",
"-XX:PrintAssemblyOptions=intel");
| protected MarkHolder markHolder; |
Plinz/Hive_Game | src/main/java/view/Highlighter.java | // Path: src/main/java/engine/Visitor.java
// public abstract class Visitor {
//
// protected abstract boolean visit(Board b);
//
// protected abstract boolean visit(Tile t);
//
// protected abstract boolean visit(Piece p);
//
// public abstract boolean visit(CoordGene<Integer> c);
//
// public abstract boolean visit(HelpMove h);
//
// }
//
// Path: src/main/java/model/HelpMove.java
// public class HelpMove {
// private boolean isAdd;
// private int pieceId;
// private CoordGene<Integer> from;
// private CoordGene<Integer> target;
//
// public HelpMove(boolean isAdd, int pieceId, CoordGene<Integer> from, CoordGene<Integer> target) {
// this.isAdd = isAdd;
// this.pieceId = pieceId;
// this.from = from;
// this.target = target;
// }
// public boolean isAdd() {
// return isAdd;
// }
// public void setAdd(boolean isAdd) {
// this.isAdd = isAdd;
// }
// public int getPieceId() {
// return pieceId;
// }
// public void setPieceId(int pieceId) {
// this.pieceId = pieceId;
// }
// public CoordGene<Integer> getFrom() {
// return from;
// }
// public void setFrom(CoordGene<Integer> from) {
// this.from = from;
// }
// public CoordGene<Integer> getTarget() {
// return target;
// }
// public void setTarget(CoordGene<Integer> target) {
// this.target = target;
// }
//
//
//
// }
//
// Path: src/main/java/utils/CoordGene.java
// public class CoordGene<T> {
//
// private T x;
// private T y;
//
// public CoordGene(T x, T y) {
// this.x = x;
// this.y = y;
// }
// public T getX() {
// return x;
// }
// public void setX(T x) {
// this.x = x;
// }
// public T getY() {
// return y;
// }
// public void setY(T y) {
// this.y = y;
// }
//
// public CoordGene<Integer> getEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getSouthEast() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getSouthWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getNorthWest() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y - 1);
// }
//
// public CoordGene<Integer> getNorthEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y - 1);
// }
//
// @Override
// public int hashCode() {
// int hash = 7;
// hash = 47 * hash + Objects.hashCode(this.x);
// hash = 47 * hash + Objects.hashCode(this.y);
// return hash;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final CoordGene<?> other = (CoordGene<?>) obj;
// if (!Objects.equals(this.x, other.x)) {
// return false;
// }
// if (!Objects.equals(this.y, other.y)) {
// return false;
// }
// return true;
// }
//
// public List<CoordGene<Integer>> getNeighbors() {
// List<CoordGene<Integer>> list = new ArrayList<CoordGene<Integer>>();
// list.add(getEast());
// list.add(getSouthEast());
// list.add(getSouthWest());
// list.add(getWest());
// list.add(getNorthWest());
// list.add(getNorthEast());
// return list;
// }
//
// @Override
// public String toString() {
// return "Coord{" + "x=" + x + ", y=" + y + '}' + '\n';
// }
//
// }
| import main.java.engine.Visitor;
import main.java.model.HelpMove;
import main.java.utils.CoordGene;
import java.util.List; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.view;
/**
*
* @author duvernet
*/
public class Highlighter {
private List<CoordGene<Integer>> listTohighlight; | // Path: src/main/java/engine/Visitor.java
// public abstract class Visitor {
//
// protected abstract boolean visit(Board b);
//
// protected abstract boolean visit(Tile t);
//
// protected abstract boolean visit(Piece p);
//
// public abstract boolean visit(CoordGene<Integer> c);
//
// public abstract boolean visit(HelpMove h);
//
// }
//
// Path: src/main/java/model/HelpMove.java
// public class HelpMove {
// private boolean isAdd;
// private int pieceId;
// private CoordGene<Integer> from;
// private CoordGene<Integer> target;
//
// public HelpMove(boolean isAdd, int pieceId, CoordGene<Integer> from, CoordGene<Integer> target) {
// this.isAdd = isAdd;
// this.pieceId = pieceId;
// this.from = from;
// this.target = target;
// }
// public boolean isAdd() {
// return isAdd;
// }
// public void setAdd(boolean isAdd) {
// this.isAdd = isAdd;
// }
// public int getPieceId() {
// return pieceId;
// }
// public void setPieceId(int pieceId) {
// this.pieceId = pieceId;
// }
// public CoordGene<Integer> getFrom() {
// return from;
// }
// public void setFrom(CoordGene<Integer> from) {
// this.from = from;
// }
// public CoordGene<Integer> getTarget() {
// return target;
// }
// public void setTarget(CoordGene<Integer> target) {
// this.target = target;
// }
//
//
//
// }
//
// Path: src/main/java/utils/CoordGene.java
// public class CoordGene<T> {
//
// private T x;
// private T y;
//
// public CoordGene(T x, T y) {
// this.x = x;
// this.y = y;
// }
// public T getX() {
// return x;
// }
// public void setX(T x) {
// this.x = x;
// }
// public T getY() {
// return y;
// }
// public void setY(T y) {
// this.y = y;
// }
//
// public CoordGene<Integer> getEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getSouthEast() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getSouthWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getNorthWest() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y - 1);
// }
//
// public CoordGene<Integer> getNorthEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y - 1);
// }
//
// @Override
// public int hashCode() {
// int hash = 7;
// hash = 47 * hash + Objects.hashCode(this.x);
// hash = 47 * hash + Objects.hashCode(this.y);
// return hash;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final CoordGene<?> other = (CoordGene<?>) obj;
// if (!Objects.equals(this.x, other.x)) {
// return false;
// }
// if (!Objects.equals(this.y, other.y)) {
// return false;
// }
// return true;
// }
//
// public List<CoordGene<Integer>> getNeighbors() {
// List<CoordGene<Integer>> list = new ArrayList<CoordGene<Integer>>();
// list.add(getEast());
// list.add(getSouthEast());
// list.add(getSouthWest());
// list.add(getWest());
// list.add(getNorthWest());
// list.add(getNorthEast());
// return list;
// }
//
// @Override
// public String toString() {
// return "Coord{" + "x=" + x + ", y=" + y + '}' + '\n';
// }
//
// }
// Path: src/main/java/view/Highlighter.java
import main.java.engine.Visitor;
import main.java.model.HelpMove;
import main.java.utils.CoordGene;
import java.util.List;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.view;
/**
*
* @author duvernet
*/
public class Highlighter {
private List<CoordGene<Integer>> listTohighlight; | private HelpMove help; |
Plinz/Hive_Game | src/main/java/view/Highlighter.java | // Path: src/main/java/engine/Visitor.java
// public abstract class Visitor {
//
// protected abstract boolean visit(Board b);
//
// protected abstract boolean visit(Tile t);
//
// protected abstract boolean visit(Piece p);
//
// public abstract boolean visit(CoordGene<Integer> c);
//
// public abstract boolean visit(HelpMove h);
//
// }
//
// Path: src/main/java/model/HelpMove.java
// public class HelpMove {
// private boolean isAdd;
// private int pieceId;
// private CoordGene<Integer> from;
// private CoordGene<Integer> target;
//
// public HelpMove(boolean isAdd, int pieceId, CoordGene<Integer> from, CoordGene<Integer> target) {
// this.isAdd = isAdd;
// this.pieceId = pieceId;
// this.from = from;
// this.target = target;
// }
// public boolean isAdd() {
// return isAdd;
// }
// public void setAdd(boolean isAdd) {
// this.isAdd = isAdd;
// }
// public int getPieceId() {
// return pieceId;
// }
// public void setPieceId(int pieceId) {
// this.pieceId = pieceId;
// }
// public CoordGene<Integer> getFrom() {
// return from;
// }
// public void setFrom(CoordGene<Integer> from) {
// this.from = from;
// }
// public CoordGene<Integer> getTarget() {
// return target;
// }
// public void setTarget(CoordGene<Integer> target) {
// this.target = target;
// }
//
//
//
// }
//
// Path: src/main/java/utils/CoordGene.java
// public class CoordGene<T> {
//
// private T x;
// private T y;
//
// public CoordGene(T x, T y) {
// this.x = x;
// this.y = y;
// }
// public T getX() {
// return x;
// }
// public void setX(T x) {
// this.x = x;
// }
// public T getY() {
// return y;
// }
// public void setY(T y) {
// this.y = y;
// }
//
// public CoordGene<Integer> getEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getSouthEast() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getSouthWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getNorthWest() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y - 1);
// }
//
// public CoordGene<Integer> getNorthEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y - 1);
// }
//
// @Override
// public int hashCode() {
// int hash = 7;
// hash = 47 * hash + Objects.hashCode(this.x);
// hash = 47 * hash + Objects.hashCode(this.y);
// return hash;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final CoordGene<?> other = (CoordGene<?>) obj;
// if (!Objects.equals(this.x, other.x)) {
// return false;
// }
// if (!Objects.equals(this.y, other.y)) {
// return false;
// }
// return true;
// }
//
// public List<CoordGene<Integer>> getNeighbors() {
// List<CoordGene<Integer>> list = new ArrayList<CoordGene<Integer>>();
// list.add(getEast());
// list.add(getSouthEast());
// list.add(getSouthWest());
// list.add(getWest());
// list.add(getNorthWest());
// list.add(getNorthEast());
// return list;
// }
//
// @Override
// public String toString() {
// return "Coord{" + "x=" + x + ", y=" + y + '}' + '\n';
// }
//
// }
| import main.java.engine.Visitor;
import main.java.model.HelpMove;
import main.java.utils.CoordGene;
import java.util.List; | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.view;
/**
*
* @author duvernet
*/
public class Highlighter {
private List<CoordGene<Integer>> listTohighlight;
private HelpMove help;
public Highlighter(){}
| // Path: src/main/java/engine/Visitor.java
// public abstract class Visitor {
//
// protected abstract boolean visit(Board b);
//
// protected abstract boolean visit(Tile t);
//
// protected abstract boolean visit(Piece p);
//
// public abstract boolean visit(CoordGene<Integer> c);
//
// public abstract boolean visit(HelpMove h);
//
// }
//
// Path: src/main/java/model/HelpMove.java
// public class HelpMove {
// private boolean isAdd;
// private int pieceId;
// private CoordGene<Integer> from;
// private CoordGene<Integer> target;
//
// public HelpMove(boolean isAdd, int pieceId, CoordGene<Integer> from, CoordGene<Integer> target) {
// this.isAdd = isAdd;
// this.pieceId = pieceId;
// this.from = from;
// this.target = target;
// }
// public boolean isAdd() {
// return isAdd;
// }
// public void setAdd(boolean isAdd) {
// this.isAdd = isAdd;
// }
// public int getPieceId() {
// return pieceId;
// }
// public void setPieceId(int pieceId) {
// this.pieceId = pieceId;
// }
// public CoordGene<Integer> getFrom() {
// return from;
// }
// public void setFrom(CoordGene<Integer> from) {
// this.from = from;
// }
// public CoordGene<Integer> getTarget() {
// return target;
// }
// public void setTarget(CoordGene<Integer> target) {
// this.target = target;
// }
//
//
//
// }
//
// Path: src/main/java/utils/CoordGene.java
// public class CoordGene<T> {
//
// private T x;
// private T y;
//
// public CoordGene(T x, T y) {
// this.x = x;
// this.y = y;
// }
// public T getX() {
// return x;
// }
// public void setX(T x) {
// this.x = x;
// }
// public T getY() {
// return y;
// }
// public void setY(T y) {
// this.y = y;
// }
//
// public CoordGene<Integer> getEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getSouthEast() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getSouthWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getNorthWest() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y - 1);
// }
//
// public CoordGene<Integer> getNorthEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y - 1);
// }
//
// @Override
// public int hashCode() {
// int hash = 7;
// hash = 47 * hash + Objects.hashCode(this.x);
// hash = 47 * hash + Objects.hashCode(this.y);
// return hash;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final CoordGene<?> other = (CoordGene<?>) obj;
// if (!Objects.equals(this.x, other.x)) {
// return false;
// }
// if (!Objects.equals(this.y, other.y)) {
// return false;
// }
// return true;
// }
//
// public List<CoordGene<Integer>> getNeighbors() {
// List<CoordGene<Integer>> list = new ArrayList<CoordGene<Integer>>();
// list.add(getEast());
// list.add(getSouthEast());
// list.add(getSouthWest());
// list.add(getWest());
// list.add(getNorthWest());
// list.add(getNorthEast());
// return list;
// }
//
// @Override
// public String toString() {
// return "Coord{" + "x=" + x + ", y=" + y + '}' + '\n';
// }
//
// }
// Path: src/main/java/view/Highlighter.java
import main.java.engine.Visitor;
import main.java.model.HelpMove;
import main.java.utils.CoordGene;
import java.util.List;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package main.java.view;
/**
*
* @author duvernet
*/
public class Highlighter {
private List<CoordGene<Integer>> listTohighlight;
private HelpMove help;
public Highlighter(){}
| public boolean accept(Visitor v){ |
Plinz/Hive_Game | src/main/java/model/HelpMove.java | // Path: src/main/java/utils/CoordGene.java
// public class CoordGene<T> {
//
// private T x;
// private T y;
//
// public CoordGene(T x, T y) {
// this.x = x;
// this.y = y;
// }
// public T getX() {
// return x;
// }
// public void setX(T x) {
// this.x = x;
// }
// public T getY() {
// return y;
// }
// public void setY(T y) {
// this.y = y;
// }
//
// public CoordGene<Integer> getEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getSouthEast() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getSouthWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getNorthWest() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y - 1);
// }
//
// public CoordGene<Integer> getNorthEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y - 1);
// }
//
// @Override
// public int hashCode() {
// int hash = 7;
// hash = 47 * hash + Objects.hashCode(this.x);
// hash = 47 * hash + Objects.hashCode(this.y);
// return hash;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final CoordGene<?> other = (CoordGene<?>) obj;
// if (!Objects.equals(this.x, other.x)) {
// return false;
// }
// if (!Objects.equals(this.y, other.y)) {
// return false;
// }
// return true;
// }
//
// public List<CoordGene<Integer>> getNeighbors() {
// List<CoordGene<Integer>> list = new ArrayList<CoordGene<Integer>>();
// list.add(getEast());
// list.add(getSouthEast());
// list.add(getSouthWest());
// list.add(getWest());
// list.add(getNorthWest());
// list.add(getNorthEast());
// return list;
// }
//
// @Override
// public String toString() {
// return "Coord{" + "x=" + x + ", y=" + y + '}' + '\n';
// }
//
// }
| import main.java.utils.CoordGene; | package main.java.model;
public class HelpMove {
private boolean isAdd;
private int pieceId; | // Path: src/main/java/utils/CoordGene.java
// public class CoordGene<T> {
//
// private T x;
// private T y;
//
// public CoordGene(T x, T y) {
// this.x = x;
// this.y = y;
// }
// public T getX() {
// return x;
// }
// public void setX(T x) {
// this.x = x;
// }
// public T getY() {
// return y;
// }
// public void setY(T y) {
// this.y = y;
// }
//
// public CoordGene<Integer> getEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getSouthEast() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getSouthWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getNorthWest() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y - 1);
// }
//
// public CoordGene<Integer> getNorthEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y - 1);
// }
//
// @Override
// public int hashCode() {
// int hash = 7;
// hash = 47 * hash + Objects.hashCode(this.x);
// hash = 47 * hash + Objects.hashCode(this.y);
// return hash;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final CoordGene<?> other = (CoordGene<?>) obj;
// if (!Objects.equals(this.x, other.x)) {
// return false;
// }
// if (!Objects.equals(this.y, other.y)) {
// return false;
// }
// return true;
// }
//
// public List<CoordGene<Integer>> getNeighbors() {
// List<CoordGene<Integer>> list = new ArrayList<CoordGene<Integer>>();
// list.add(getEast());
// list.add(getSouthEast());
// list.add(getSouthWest());
// list.add(getWest());
// list.add(getNorthWest());
// list.add(getNorthEast());
// return list;
// }
//
// @Override
// public String toString() {
// return "Coord{" + "x=" + x + ", y=" + y + '}' + '\n';
// }
//
// }
// Path: src/main/java/model/HelpMove.java
import main.java.utils.CoordGene;
package main.java.model;
public class HelpMove {
private boolean isAdd;
private int pieceId; | private CoordGene<Integer> from; |
Plinz/Hive_Game | src/main/java/model/Piece.java | // Path: src/main/java/utils/CoordGene.java
// public class CoordGene<T> {
//
// private T x;
// private T y;
//
// public CoordGene(T x, T y) {
// this.x = x;
// this.y = y;
// }
// public T getX() {
// return x;
// }
// public void setX(T x) {
// this.x = x;
// }
// public T getY() {
// return y;
// }
// public void setY(T y) {
// this.y = y;
// }
//
// public CoordGene<Integer> getEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getSouthEast() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getSouthWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getNorthWest() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y - 1);
// }
//
// public CoordGene<Integer> getNorthEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y - 1);
// }
//
// @Override
// public int hashCode() {
// int hash = 7;
// hash = 47 * hash + Objects.hashCode(this.x);
// hash = 47 * hash + Objects.hashCode(this.y);
// return hash;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final CoordGene<?> other = (CoordGene<?>) obj;
// if (!Objects.equals(this.x, other.x)) {
// return false;
// }
// if (!Objects.equals(this.y, other.y)) {
// return false;
// }
// return true;
// }
//
// public List<CoordGene<Integer>> getNeighbors() {
// List<CoordGene<Integer>> list = new ArrayList<CoordGene<Integer>>();
// list.add(getEast());
// list.add(getSouthEast());
// list.add(getSouthWest());
// list.add(getWest());
// list.add(getNorthWest());
// list.add(getNorthEast());
// return list;
// }
//
// @Override
// public String toString() {
// return "Coord{" + "x=" + x + ", y=" + y + '}' + '\n';
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import javafx.scene.image.Image;
import main.java.utils.CoordGene; | package main.java.model;
public abstract class Piece implements Cloneable{
protected String name;
protected int id;
protected int team;
protected Image image;
protected String description; | // Path: src/main/java/utils/CoordGene.java
// public class CoordGene<T> {
//
// private T x;
// private T y;
//
// public CoordGene(T x, T y) {
// this.x = x;
// this.y = y;
// }
// public T getX() {
// return x;
// }
// public void setX(T x) {
// this.x = x;
// }
// public T getY() {
// return y;
// }
// public void setY(T y) {
// this.y = y;
// }
//
// public CoordGene<Integer> getEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getSouthEast() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getSouthWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y + 1);
// }
//
// public CoordGene<Integer> getWest() {
// return new CoordGene<Integer>((Integer)this.x - 1, (Integer)this.y);
// }
//
// public CoordGene<Integer> getNorthWest() {
// return new CoordGene<Integer>((Integer)this.x, (Integer)this.y - 1);
// }
//
// public CoordGene<Integer> getNorthEast() {
// return new CoordGene<Integer>((Integer)this.x + 1, (Integer)this.y - 1);
// }
//
// @Override
// public int hashCode() {
// int hash = 7;
// hash = 47 * hash + Objects.hashCode(this.x);
// hash = 47 * hash + Objects.hashCode(this.y);
// return hash;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// final CoordGene<?> other = (CoordGene<?>) obj;
// if (!Objects.equals(this.x, other.x)) {
// return false;
// }
// if (!Objects.equals(this.y, other.y)) {
// return false;
// }
// return true;
// }
//
// public List<CoordGene<Integer>> getNeighbors() {
// List<CoordGene<Integer>> list = new ArrayList<CoordGene<Integer>>();
// list.add(getEast());
// list.add(getSouthEast());
// list.add(getSouthWest());
// list.add(getWest());
// list.add(getNorthWest());
// list.add(getNorthEast());
// return list;
// }
//
// @Override
// public String toString() {
// return "Coord{" + "x=" + x + ", y=" + y + '}' + '\n';
// }
//
// }
// Path: src/main/java/model/Piece.java
import java.util.ArrayList;
import java.util.List;
import javafx.scene.image.Image;
import main.java.utils.CoordGene;
package main.java.model;
public abstract class Piece implements Cloneable{
protected String name;
protected int id;
protected int team;
protected Image image;
protected String description; | protected List<CoordGene<Integer>> possibleMovement; |
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/web/WebUtils.java | // Path: src/main/java/org/esupportail/papercut/security/ContextUserDetails.java
// public class ContextUserDetails implements UserDetails {
//
// private static final long serialVersionUID = 1L;
//
// String username;
//
// Map<String, Set<GrantedAuthority>> contextAuthorities = new HashMap<String, Set<GrantedAuthority>>();
// Map<String, String> contextUids = new HashMap<String, String>();
// Map<String, String> contextEmails = new HashMap<String, String>();
//
// final List<GrantedAuthority> defaultAuthorities = Arrays.asList(new GrantedAuthority[] {new SimpleGrantedAuthority("ROLE_NONE")});
//
// List<String> availableContexts;
//
// public ContextUserDetails(String username, Map<String, Set<GrantedAuthority>> contextAuthorities, Map<String, String> contextUids, Map<String, String> contextEmails, List<String> availableContexts) {
// this.username = username;
// this.contextAuthorities = contextAuthorities;
// this.contextUids = contextUids;
// this.contextEmails = contextEmails;
// this.availableContexts = availableContexts;
// }
//
// @Override
// public Collection<? extends GrantedAuthority> getAuthorities() {
// RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// if (requestAttributes != null && requestAttributes instanceof ServletRequestAttributes) {
// HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest();
// String papercutContext = WebUtils.getContext(request);
// if(contextAuthorities.get(papercutContext) != null && !contextAuthorities.get(papercutContext).isEmpty()) {
// return contextAuthorities.get(papercutContext);
// }
// }
// return defaultAuthorities;
// }
//
// @Override
// public String getPassword() {
// return null;
// }
//
// @Override
// public String getUsername() {
// RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// if (requestAttributes != null && requestAttributes instanceof ServletRequestAttributes) {
// HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest();
// String papercutContext = WebUtils.getContext(request);
// if(contextUids.get(papercutContext) != null && !contextUids.get(papercutContext).isEmpty()) {
// return contextUids.get(papercutContext);
// }
// }
// return username;
// }
//
// public String getEmail() {
// RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// if (requestAttributes != null && requestAttributes instanceof ServletRequestAttributes) {
// HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest();
// String papercutContext = WebUtils.getContext(request);
// if(contextEmails.get(papercutContext) != null && !contextEmails.get(papercutContext).isEmpty()) {
// return contextEmails.get(papercutContext);
// }
// }
// return null;
// }
//
// @Override
// public boolean isAccountNonExpired() {
// return true;
// }
//
// @Override
// public boolean isAccountNonLocked() {
// return true;
// }
//
// @Override
// public boolean isCredentialsNonExpired() {
// return true;
// }
//
// @Override
// public boolean isEnabled() {
// return true;
// }
//
// public List<String> getAvailableContexts() {
// return availableContexts;
// }
//
// }
| import java.util.ArrayList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import org.esupportail.papercut.security.ContextUserDetails;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder; | /**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.web;
public class WebUtils {
public static String getContext(HttpServletRequest request) {
String path = request.getServletPath();
if("/error".equals(path)) {
path = (String)request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);
}
String papercutContext = path.replaceFirst("/([^/]*).*", "$1");
return papercutContext;
}
public static List<String> availableContexts() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication(); | // Path: src/main/java/org/esupportail/papercut/security/ContextUserDetails.java
// public class ContextUserDetails implements UserDetails {
//
// private static final long serialVersionUID = 1L;
//
// String username;
//
// Map<String, Set<GrantedAuthority>> contextAuthorities = new HashMap<String, Set<GrantedAuthority>>();
// Map<String, String> contextUids = new HashMap<String, String>();
// Map<String, String> contextEmails = new HashMap<String, String>();
//
// final List<GrantedAuthority> defaultAuthorities = Arrays.asList(new GrantedAuthority[] {new SimpleGrantedAuthority("ROLE_NONE")});
//
// List<String> availableContexts;
//
// public ContextUserDetails(String username, Map<String, Set<GrantedAuthority>> contextAuthorities, Map<String, String> contextUids, Map<String, String> contextEmails, List<String> availableContexts) {
// this.username = username;
// this.contextAuthorities = contextAuthorities;
// this.contextUids = contextUids;
// this.contextEmails = contextEmails;
// this.availableContexts = availableContexts;
// }
//
// @Override
// public Collection<? extends GrantedAuthority> getAuthorities() {
// RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// if (requestAttributes != null && requestAttributes instanceof ServletRequestAttributes) {
// HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest();
// String papercutContext = WebUtils.getContext(request);
// if(contextAuthorities.get(papercutContext) != null && !contextAuthorities.get(papercutContext).isEmpty()) {
// return contextAuthorities.get(papercutContext);
// }
// }
// return defaultAuthorities;
// }
//
// @Override
// public String getPassword() {
// return null;
// }
//
// @Override
// public String getUsername() {
// RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// if (requestAttributes != null && requestAttributes instanceof ServletRequestAttributes) {
// HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest();
// String papercutContext = WebUtils.getContext(request);
// if(contextUids.get(papercutContext) != null && !contextUids.get(papercutContext).isEmpty()) {
// return contextUids.get(papercutContext);
// }
// }
// return username;
// }
//
// public String getEmail() {
// RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
// if (requestAttributes != null && requestAttributes instanceof ServletRequestAttributes) {
// HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest();
// String papercutContext = WebUtils.getContext(request);
// if(contextEmails.get(papercutContext) != null && !contextEmails.get(papercutContext).isEmpty()) {
// return contextEmails.get(papercutContext);
// }
// }
// return null;
// }
//
// @Override
// public boolean isAccountNonExpired() {
// return true;
// }
//
// @Override
// public boolean isAccountNonLocked() {
// return true;
// }
//
// @Override
// public boolean isCredentialsNonExpired() {
// return true;
// }
//
// @Override
// public boolean isEnabled() {
// return true;
// }
//
// public List<String> getAvailableContexts() {
// return availableContexts;
// }
//
// }
// Path: src/main/java/org/esupportail/papercut/web/WebUtils.java
import java.util.ArrayList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import org.esupportail.papercut.security.ContextUserDetails;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.web;
public class WebUtils {
public static String getContext(HttpServletRequest request) {
String path = request.getServletPath();
if("/error".equals(path)) {
path = (String)request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);
}
String papercutContext = path.replaceFirst("/([^/]*).*", "$1");
return papercutContext;
}
public static List<String> availableContexts() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication(); | if(auth != null && auth.getPrincipal() instanceof ContextUserDetails) { |
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/dao/PapercutDaoService.java | // Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// @Entity
// @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "papercutContext", type = "string")})
// @Filter(name = "contextFilter", condition = "papercut_context = :papercutContext")
// public class PayPapercutTransactionLog implements ContextSupport {
//
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Temporal(TemporalType.TIMESTAMP)
// @DateTimeFormat(style = "dd/MM/yyyy-HH:mm:ss")
// private Date transactionDate;
//
// @Enumerated(EnumType.STRING)
// private PayMode payMode;
//
// private String uid;
//
// private String papercutContext;
//
// private String reference;
//
// private Integer montant;
//
// private String papercutNewSolde;
//
// private String idtrans;
//
// private String papercutOldSolde;
//
// private Boolean archived = false;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Date getTransactionDate() {
// return transactionDate;
// }
//
// public void setTransactionDate(Date transactionDate) {
// this.transactionDate = transactionDate;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getPapercutContext() {
// return papercutContext;
// }
//
// public void setPapercutContext(String papercutContext) {
// this.papercutContext = papercutContext;
// }
//
// public PayMode getPayMode() {
// return payMode;
// }
//
// public void setPayMode(PayMode payMode) {
// this.payMode = payMode;
// }
//
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public Integer getMontant() {
// return montant;
// }
//
// public void setMontant(Integer montant) {
// this.montant = montant;
// }
//
// public String getPapercutNewSolde() {
// return papercutNewSolde;
// }
//
// public void setPapercutNewSolde(String papercutNewSolde) {
// this.papercutNewSolde = papercutNewSolde;
// }
//
// public String getIdtrans() {
// return idtrans;
// }
//
// public void setIdtrans(String idtrans) {
// this.idtrans = idtrans;
// }
//
// public String getPapercutOldSolde() {
// return papercutOldSolde;
// }
//
// public void setPapercutOldSolde(String papercutOldSolde) {
// this.papercutOldSolde = papercutOldSolde;
// }
//
// public Boolean getArchived() {
// return archived;
// }
//
// public void setArchived(Boolean archived) {
// this.archived = archived;
// }
//
// public String getMontantDevise() {
// Double mnt = new Double(montant)/100.0;
// return mnt.toString();
// }
//
// }
//
// Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// Path: src/main/java/org/esupportail/papercut/security/ContextHelper.java
// public class ContextHelper {
//
// private static ThreadLocal<String> currentContext = new ThreadLocal<>();
//
// public static String getCurrentContext() {
// return currentContext.get();
// }
//
// public static void setCurrentContext(String context) {
// currentContext.set(context);
// }
//
// public static void clear() {
// currentContext.set(null);
// }
//
// }
| import java.time.Duration;
import java.time.Instant;
import java.util.Date;
import java.util.List;
import org.esupportail.papercut.domain.PayPapercutTransactionLog;
import org.esupportail.papercut.domain.PayPapercutTransactionLog.PayMode;
import org.esupportail.papercut.security.ContextHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery; | /**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.dao;
@Service
public class PapercutDaoService {
@PersistenceContext
public EntityManager entityManager;
@Autowired
private PayPapercutTransactionLogRepository txRepository;
@Transactional | // Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// @Entity
// @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "papercutContext", type = "string")})
// @Filter(name = "contextFilter", condition = "papercut_context = :papercutContext")
// public class PayPapercutTransactionLog implements ContextSupport {
//
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Temporal(TemporalType.TIMESTAMP)
// @DateTimeFormat(style = "dd/MM/yyyy-HH:mm:ss")
// private Date transactionDate;
//
// @Enumerated(EnumType.STRING)
// private PayMode payMode;
//
// private String uid;
//
// private String papercutContext;
//
// private String reference;
//
// private Integer montant;
//
// private String papercutNewSolde;
//
// private String idtrans;
//
// private String papercutOldSolde;
//
// private Boolean archived = false;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Date getTransactionDate() {
// return transactionDate;
// }
//
// public void setTransactionDate(Date transactionDate) {
// this.transactionDate = transactionDate;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getPapercutContext() {
// return papercutContext;
// }
//
// public void setPapercutContext(String papercutContext) {
// this.papercutContext = papercutContext;
// }
//
// public PayMode getPayMode() {
// return payMode;
// }
//
// public void setPayMode(PayMode payMode) {
// this.payMode = payMode;
// }
//
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public Integer getMontant() {
// return montant;
// }
//
// public void setMontant(Integer montant) {
// this.montant = montant;
// }
//
// public String getPapercutNewSolde() {
// return papercutNewSolde;
// }
//
// public void setPapercutNewSolde(String papercutNewSolde) {
// this.papercutNewSolde = papercutNewSolde;
// }
//
// public String getIdtrans() {
// return idtrans;
// }
//
// public void setIdtrans(String idtrans) {
// this.idtrans = idtrans;
// }
//
// public String getPapercutOldSolde() {
// return papercutOldSolde;
// }
//
// public void setPapercutOldSolde(String papercutOldSolde) {
// this.papercutOldSolde = papercutOldSolde;
// }
//
// public Boolean getArchived() {
// return archived;
// }
//
// public void setArchived(Boolean archived) {
// this.archived = archived;
// }
//
// public String getMontantDevise() {
// Double mnt = new Double(montant)/100.0;
// return mnt.toString();
// }
//
// }
//
// Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// Path: src/main/java/org/esupportail/papercut/security/ContextHelper.java
// public class ContextHelper {
//
// private static ThreadLocal<String> currentContext = new ThreadLocal<>();
//
// public static String getCurrentContext() {
// return currentContext.get();
// }
//
// public static void setCurrentContext(String context) {
// currentContext.set(context);
// }
//
// public static void clear() {
// currentContext.set(null);
// }
//
// }
// Path: src/main/java/org/esupportail/papercut/dao/PapercutDaoService.java
import java.time.Duration;
import java.time.Instant;
import java.util.Date;
import java.util.List;
import org.esupportail.papercut.domain.PayPapercutTransactionLog;
import org.esupportail.papercut.domain.PayPapercutTransactionLog.PayMode;
import org.esupportail.papercut.security.ContextHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.dao;
@Service
public class PapercutDaoService {
@PersistenceContext
public EntityManager entityManager;
@Autowired
private PayPapercutTransactionLogRepository txRepository;
@Transactional | public void persist(PayPapercutTransactionLog txLog) { |
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/dao/PapercutDaoService.java | // Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// @Entity
// @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "papercutContext", type = "string")})
// @Filter(name = "contextFilter", condition = "papercut_context = :papercutContext")
// public class PayPapercutTransactionLog implements ContextSupport {
//
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Temporal(TemporalType.TIMESTAMP)
// @DateTimeFormat(style = "dd/MM/yyyy-HH:mm:ss")
// private Date transactionDate;
//
// @Enumerated(EnumType.STRING)
// private PayMode payMode;
//
// private String uid;
//
// private String papercutContext;
//
// private String reference;
//
// private Integer montant;
//
// private String papercutNewSolde;
//
// private String idtrans;
//
// private String papercutOldSolde;
//
// private Boolean archived = false;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Date getTransactionDate() {
// return transactionDate;
// }
//
// public void setTransactionDate(Date transactionDate) {
// this.transactionDate = transactionDate;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getPapercutContext() {
// return papercutContext;
// }
//
// public void setPapercutContext(String papercutContext) {
// this.papercutContext = papercutContext;
// }
//
// public PayMode getPayMode() {
// return payMode;
// }
//
// public void setPayMode(PayMode payMode) {
// this.payMode = payMode;
// }
//
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public Integer getMontant() {
// return montant;
// }
//
// public void setMontant(Integer montant) {
// this.montant = montant;
// }
//
// public String getPapercutNewSolde() {
// return papercutNewSolde;
// }
//
// public void setPapercutNewSolde(String papercutNewSolde) {
// this.papercutNewSolde = papercutNewSolde;
// }
//
// public String getIdtrans() {
// return idtrans;
// }
//
// public void setIdtrans(String idtrans) {
// this.idtrans = idtrans;
// }
//
// public String getPapercutOldSolde() {
// return papercutOldSolde;
// }
//
// public void setPapercutOldSolde(String papercutOldSolde) {
// this.papercutOldSolde = papercutOldSolde;
// }
//
// public Boolean getArchived() {
// return archived;
// }
//
// public void setArchived(Boolean archived) {
// this.archived = archived;
// }
//
// public String getMontantDevise() {
// Double mnt = new Double(montant)/100.0;
// return mnt.toString();
// }
//
// }
//
// Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// Path: src/main/java/org/esupportail/papercut/security/ContextHelper.java
// public class ContextHelper {
//
// private static ThreadLocal<String> currentContext = new ThreadLocal<>();
//
// public static String getCurrentContext() {
// return currentContext.get();
// }
//
// public static void setCurrentContext(String context) {
// currentContext.set(context);
// }
//
// public static void clear() {
// currentContext.set(null);
// }
//
// }
| import java.time.Duration;
import java.time.Instant;
import java.util.Date;
import java.util.List;
import org.esupportail.papercut.domain.PayPapercutTransactionLog;
import org.esupportail.papercut.domain.PayPapercutTransactionLog.PayMode;
import org.esupportail.papercut.security.ContextHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery; | public void remove(PayPapercutTransactionLog txLog) {
if (entityManager.contains(txLog)) {
entityManager.remove(txLog);
} else {
PayPapercutTransactionLog attached = txRepository.findById(txLog.getId()).get();
entityManager.remove(attached);
}
}
@Transactional
public void flush() {
entityManager.flush();
}
@Transactional
public void clear() {
entityManager.clear();
}
@Transactional
public PayPapercutTransactionLog merge(PayPapercutTransactionLog txLog) {
PayPapercutTransactionLog merged = entityManager.merge(txLog);
entityManager.flush();
return merged;
}
public Long countByUidAndArchived(String uid, boolean archived) {
return txRepository.countByUidAndArchived(uid, archived);
}
| // Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// @Entity
// @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "papercutContext", type = "string")})
// @Filter(name = "contextFilter", condition = "papercut_context = :papercutContext")
// public class PayPapercutTransactionLog implements ContextSupport {
//
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Temporal(TemporalType.TIMESTAMP)
// @DateTimeFormat(style = "dd/MM/yyyy-HH:mm:ss")
// private Date transactionDate;
//
// @Enumerated(EnumType.STRING)
// private PayMode payMode;
//
// private String uid;
//
// private String papercutContext;
//
// private String reference;
//
// private Integer montant;
//
// private String papercutNewSolde;
//
// private String idtrans;
//
// private String papercutOldSolde;
//
// private Boolean archived = false;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Date getTransactionDate() {
// return transactionDate;
// }
//
// public void setTransactionDate(Date transactionDate) {
// this.transactionDate = transactionDate;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getPapercutContext() {
// return papercutContext;
// }
//
// public void setPapercutContext(String papercutContext) {
// this.papercutContext = papercutContext;
// }
//
// public PayMode getPayMode() {
// return payMode;
// }
//
// public void setPayMode(PayMode payMode) {
// this.payMode = payMode;
// }
//
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public Integer getMontant() {
// return montant;
// }
//
// public void setMontant(Integer montant) {
// this.montant = montant;
// }
//
// public String getPapercutNewSolde() {
// return papercutNewSolde;
// }
//
// public void setPapercutNewSolde(String papercutNewSolde) {
// this.papercutNewSolde = papercutNewSolde;
// }
//
// public String getIdtrans() {
// return idtrans;
// }
//
// public void setIdtrans(String idtrans) {
// this.idtrans = idtrans;
// }
//
// public String getPapercutOldSolde() {
// return papercutOldSolde;
// }
//
// public void setPapercutOldSolde(String papercutOldSolde) {
// this.papercutOldSolde = papercutOldSolde;
// }
//
// public Boolean getArchived() {
// return archived;
// }
//
// public void setArchived(Boolean archived) {
// this.archived = archived;
// }
//
// public String getMontantDevise() {
// Double mnt = new Double(montant)/100.0;
// return mnt.toString();
// }
//
// }
//
// Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// Path: src/main/java/org/esupportail/papercut/security/ContextHelper.java
// public class ContextHelper {
//
// private static ThreadLocal<String> currentContext = new ThreadLocal<>();
//
// public static String getCurrentContext() {
// return currentContext.get();
// }
//
// public static void setCurrentContext(String context) {
// currentContext.set(context);
// }
//
// public static void clear() {
// currentContext.set(null);
// }
//
// }
// Path: src/main/java/org/esupportail/papercut/dao/PapercutDaoService.java
import java.time.Duration;
import java.time.Instant;
import java.util.Date;
import java.util.List;
import org.esupportail.papercut.domain.PayPapercutTransactionLog;
import org.esupportail.papercut.domain.PayPapercutTransactionLog.PayMode;
import org.esupportail.papercut.security.ContextHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
public void remove(PayPapercutTransactionLog txLog) {
if (entityManager.contains(txLog)) {
entityManager.remove(txLog);
} else {
PayPapercutTransactionLog attached = txRepository.findById(txLog.getId()).get();
entityManager.remove(attached);
}
}
@Transactional
public void flush() {
entityManager.flush();
}
@Transactional
public void clear() {
entityManager.clear();
}
@Transactional
public PayPapercutTransactionLog merge(PayPapercutTransactionLog txLog) {
PayPapercutTransactionLog merged = entityManager.merge(txLog);
entityManager.flush();
return merged;
}
public Long countByUidAndArchived(String uid, boolean archived) {
return txRepository.countByUidAndArchived(uid, archived);
}
| public Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByIdtransAndPayMode(String idTrans, PayMode payMode, Pageable pageable) { |
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/security/ContextUserDetails.java | // Path: src/main/java/org/esupportail/papercut/web/WebUtils.java
// public class WebUtils {
//
// public static String getContext(HttpServletRequest request) {
// String path = request.getServletPath();
// if("/error".equals(path)) {
// path = (String)request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);
// }
// String papercutContext = path.replaceFirst("/([^/]*).*", "$1");
// return papercutContext;
// }
//
// public static List<String> availableContexts() {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// if(auth != null && auth.getPrincipal() instanceof ContextUserDetails) {
// ContextUserDetails userDetails = (ContextUserDetails)auth.getPrincipal();
// return userDetails.getAvailableContexts();
// } else {
// return new ArrayList<String>();
// }
// }
//
// public static boolean isUser() {
// return hasRole("ROLE_USER");
// }
//
// public static boolean isManager() {
// return hasRole("ROLE_MANAGER");
// }
//
// public static boolean isAdmin() {
// return hasRole("ROLE_ADMIN");
// }
//
// private static boolean hasRole(String roleName) {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// return auth!=null && auth.getAuthorities() != null && auth.getAuthorities().contains(new SimpleGrantedAuthority(roleName));
// }
// }
| import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.esupportail.papercut.web.WebUtils;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority; | /**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.security;
public class ContextUserDetails implements UserDetails {
private static final long serialVersionUID = 1L;
String username;
Map<String, Set<GrantedAuthority>> contextAuthorities = new HashMap<String, Set<GrantedAuthority>>();
Map<String, String> contextUids = new HashMap<String, String>();
Map<String, String> contextEmails = new HashMap<String, String>();
final List<GrantedAuthority> defaultAuthorities = Arrays.asList(new GrantedAuthority[] {new SimpleGrantedAuthority("ROLE_NONE")});
List<String> availableContexts;
public ContextUserDetails(String username, Map<String, Set<GrantedAuthority>> contextAuthorities, Map<String, String> contextUids, Map<String, String> contextEmails, List<String> availableContexts) {
this.username = username;
this.contextAuthorities = contextAuthorities;
this.contextUids = contextUids;
this.contextEmails = contextEmails;
this.availableContexts = availableContexts;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
if (requestAttributes != null && requestAttributes instanceof ServletRequestAttributes) {
HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest(); | // Path: src/main/java/org/esupportail/papercut/web/WebUtils.java
// public class WebUtils {
//
// public static String getContext(HttpServletRequest request) {
// String path = request.getServletPath();
// if("/error".equals(path)) {
// path = (String)request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);
// }
// String papercutContext = path.replaceFirst("/([^/]*).*", "$1");
// return papercutContext;
// }
//
// public static List<String> availableContexts() {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// if(auth != null && auth.getPrincipal() instanceof ContextUserDetails) {
// ContextUserDetails userDetails = (ContextUserDetails)auth.getPrincipal();
// return userDetails.getAvailableContexts();
// } else {
// return new ArrayList<String>();
// }
// }
//
// public static boolean isUser() {
// return hasRole("ROLE_USER");
// }
//
// public static boolean isManager() {
// return hasRole("ROLE_MANAGER");
// }
//
// public static boolean isAdmin() {
// return hasRole("ROLE_ADMIN");
// }
//
// private static boolean hasRole(String roleName) {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// return auth!=null && auth.getAuthorities() != null && auth.getAuthorities().contains(new SimpleGrantedAuthority(roleName));
// }
// }
// Path: src/main/java/org/esupportail/papercut/security/ContextUserDetails.java
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.esupportail.papercut.web.WebUtils;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.security;
public class ContextUserDetails implements UserDetails {
private static final long serialVersionUID = 1L;
String username;
Map<String, Set<GrantedAuthority>> contextAuthorities = new HashMap<String, Set<GrantedAuthority>>();
Map<String, String> contextUids = new HashMap<String, String>();
Map<String, String> contextEmails = new HashMap<String, String>();
final List<GrantedAuthority> defaultAuthorities = Arrays.asList(new GrantedAuthority[] {new SimpleGrantedAuthority("ROLE_NONE")});
List<String> availableContexts;
public ContextUserDetails(String username, Map<String, Set<GrantedAuthority>> contextAuthorities, Map<String, String> contextUids, Map<String, String> contextEmails, List<String> availableContexts) {
this.username = username;
this.contextAuthorities = contextAuthorities;
this.contextUids = contextUids;
this.contextEmails = contextEmails;
this.availableContexts = availableContexts;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
if (requestAttributes != null && requestAttributes instanceof ServletRequestAttributes) {
HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest(); | String papercutContext = WebUtils.getContext(request); |
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/services/AnonymizeOneService.java | // Path: src/main/java/org/esupportail/papercut/dao/PayPapercutTransactionLogRepository.java
// @Repository
// public interface PayPapercutTransactionLogRepository extends JpaRepository<PayPapercutTransactionLog, Long>{
//
// Long countByUidAndArchived(String uid, Boolean archived);
//
// List<PayPapercutTransactionLog> findAllByTransactionDateBeforeAndUidIsNotLike(Date oldDate, String uid);
//
// Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByIdtransAndPayMode(String idTrans, PayMode payMode, Pageable pageable);
//
// Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByUid(String uid, Pageable pageable);
//
// Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByUidAndArchived(String uid, Boolean archived, Pageable pageable);
//
// }
//
// Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// @Entity
// @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "papercutContext", type = "string")})
// @Filter(name = "contextFilter", condition = "papercut_context = :papercutContext")
// public class PayPapercutTransactionLog implements ContextSupport {
//
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Temporal(TemporalType.TIMESTAMP)
// @DateTimeFormat(style = "dd/MM/yyyy-HH:mm:ss")
// private Date transactionDate;
//
// @Enumerated(EnumType.STRING)
// private PayMode payMode;
//
// private String uid;
//
// private String papercutContext;
//
// private String reference;
//
// private Integer montant;
//
// private String papercutNewSolde;
//
// private String idtrans;
//
// private String papercutOldSolde;
//
// private Boolean archived = false;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Date getTransactionDate() {
// return transactionDate;
// }
//
// public void setTransactionDate(Date transactionDate) {
// this.transactionDate = transactionDate;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getPapercutContext() {
// return papercutContext;
// }
//
// public void setPapercutContext(String papercutContext) {
// this.papercutContext = papercutContext;
// }
//
// public PayMode getPayMode() {
// return payMode;
// }
//
// public void setPayMode(PayMode payMode) {
// this.payMode = payMode;
// }
//
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public Integer getMontant() {
// return montant;
// }
//
// public void setMontant(Integer montant) {
// this.montant = montant;
// }
//
// public String getPapercutNewSolde() {
// return papercutNewSolde;
// }
//
// public void setPapercutNewSolde(String papercutNewSolde) {
// this.papercutNewSolde = papercutNewSolde;
// }
//
// public String getIdtrans() {
// return idtrans;
// }
//
// public void setIdtrans(String idtrans) {
// this.idtrans = idtrans;
// }
//
// public String getPapercutOldSolde() {
// return papercutOldSolde;
// }
//
// public void setPapercutOldSolde(String papercutOldSolde) {
// this.papercutOldSolde = papercutOldSolde;
// }
//
// public Boolean getArchived() {
// return archived;
// }
//
// public void setArchived(Boolean archived) {
// this.archived = archived;
// }
//
// public String getMontantDevise() {
// Double mnt = new Double(montant)/100.0;
// return mnt.toString();
// }
//
// }
| import org.esupportail.papercut.dao.PayPapercutTransactionLogRepository;
import org.esupportail.papercut.domain.PayPapercutTransactionLog;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; | /**
* Licensed to ESUP-Portail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* ESUP-Portail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.services;
@Service
public class AnonymizeOneService {
@Resource | // Path: src/main/java/org/esupportail/papercut/dao/PayPapercutTransactionLogRepository.java
// @Repository
// public interface PayPapercutTransactionLogRepository extends JpaRepository<PayPapercutTransactionLog, Long>{
//
// Long countByUidAndArchived(String uid, Boolean archived);
//
// List<PayPapercutTransactionLog> findAllByTransactionDateBeforeAndUidIsNotLike(Date oldDate, String uid);
//
// Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByIdtransAndPayMode(String idTrans, PayMode payMode, Pageable pageable);
//
// Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByUid(String uid, Pageable pageable);
//
// Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByUidAndArchived(String uid, Boolean archived, Pageable pageable);
//
// }
//
// Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// @Entity
// @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "papercutContext", type = "string")})
// @Filter(name = "contextFilter", condition = "papercut_context = :papercutContext")
// public class PayPapercutTransactionLog implements ContextSupport {
//
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Temporal(TemporalType.TIMESTAMP)
// @DateTimeFormat(style = "dd/MM/yyyy-HH:mm:ss")
// private Date transactionDate;
//
// @Enumerated(EnumType.STRING)
// private PayMode payMode;
//
// private String uid;
//
// private String papercutContext;
//
// private String reference;
//
// private Integer montant;
//
// private String papercutNewSolde;
//
// private String idtrans;
//
// private String papercutOldSolde;
//
// private Boolean archived = false;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Date getTransactionDate() {
// return transactionDate;
// }
//
// public void setTransactionDate(Date transactionDate) {
// this.transactionDate = transactionDate;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getPapercutContext() {
// return papercutContext;
// }
//
// public void setPapercutContext(String papercutContext) {
// this.papercutContext = papercutContext;
// }
//
// public PayMode getPayMode() {
// return payMode;
// }
//
// public void setPayMode(PayMode payMode) {
// this.payMode = payMode;
// }
//
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public Integer getMontant() {
// return montant;
// }
//
// public void setMontant(Integer montant) {
// this.montant = montant;
// }
//
// public String getPapercutNewSolde() {
// return papercutNewSolde;
// }
//
// public void setPapercutNewSolde(String papercutNewSolde) {
// this.papercutNewSolde = papercutNewSolde;
// }
//
// public String getIdtrans() {
// return idtrans;
// }
//
// public void setIdtrans(String idtrans) {
// this.idtrans = idtrans;
// }
//
// public String getPapercutOldSolde() {
// return papercutOldSolde;
// }
//
// public void setPapercutOldSolde(String papercutOldSolde) {
// this.papercutOldSolde = papercutOldSolde;
// }
//
// public Boolean getArchived() {
// return archived;
// }
//
// public void setArchived(Boolean archived) {
// this.archived = archived;
// }
//
// public String getMontantDevise() {
// Double mnt = new Double(montant)/100.0;
// return mnt.toString();
// }
//
// }
// Path: src/main/java/org/esupportail/papercut/services/AnonymizeOneService.java
import org.esupportail.papercut.dao.PayPapercutTransactionLogRepository;
import org.esupportail.papercut.domain.PayPapercutTransactionLog;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* Licensed to ESUP-Portail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* ESUP-Portail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.services;
@Service
public class AnonymizeOneService {
@Resource | PayPapercutTransactionLogRepository payPapercutTransactionLogRepository; |
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/services/AnonymizeOneService.java | // Path: src/main/java/org/esupportail/papercut/dao/PayPapercutTransactionLogRepository.java
// @Repository
// public interface PayPapercutTransactionLogRepository extends JpaRepository<PayPapercutTransactionLog, Long>{
//
// Long countByUidAndArchived(String uid, Boolean archived);
//
// List<PayPapercutTransactionLog> findAllByTransactionDateBeforeAndUidIsNotLike(Date oldDate, String uid);
//
// Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByIdtransAndPayMode(String idTrans, PayMode payMode, Pageable pageable);
//
// Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByUid(String uid, Pageable pageable);
//
// Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByUidAndArchived(String uid, Boolean archived, Pageable pageable);
//
// }
//
// Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// @Entity
// @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "papercutContext", type = "string")})
// @Filter(name = "contextFilter", condition = "papercut_context = :papercutContext")
// public class PayPapercutTransactionLog implements ContextSupport {
//
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Temporal(TemporalType.TIMESTAMP)
// @DateTimeFormat(style = "dd/MM/yyyy-HH:mm:ss")
// private Date transactionDate;
//
// @Enumerated(EnumType.STRING)
// private PayMode payMode;
//
// private String uid;
//
// private String papercutContext;
//
// private String reference;
//
// private Integer montant;
//
// private String papercutNewSolde;
//
// private String idtrans;
//
// private String papercutOldSolde;
//
// private Boolean archived = false;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Date getTransactionDate() {
// return transactionDate;
// }
//
// public void setTransactionDate(Date transactionDate) {
// this.transactionDate = transactionDate;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getPapercutContext() {
// return papercutContext;
// }
//
// public void setPapercutContext(String papercutContext) {
// this.papercutContext = papercutContext;
// }
//
// public PayMode getPayMode() {
// return payMode;
// }
//
// public void setPayMode(PayMode payMode) {
// this.payMode = payMode;
// }
//
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public Integer getMontant() {
// return montant;
// }
//
// public void setMontant(Integer montant) {
// this.montant = montant;
// }
//
// public String getPapercutNewSolde() {
// return papercutNewSolde;
// }
//
// public void setPapercutNewSolde(String papercutNewSolde) {
// this.papercutNewSolde = papercutNewSolde;
// }
//
// public String getIdtrans() {
// return idtrans;
// }
//
// public void setIdtrans(String idtrans) {
// this.idtrans = idtrans;
// }
//
// public String getPapercutOldSolde() {
// return papercutOldSolde;
// }
//
// public void setPapercutOldSolde(String papercutOldSolde) {
// this.papercutOldSolde = papercutOldSolde;
// }
//
// public Boolean getArchived() {
// return archived;
// }
//
// public void setArchived(Boolean archived) {
// this.archived = archived;
// }
//
// public String getMontantDevise() {
// Double mnt = new Double(montant)/100.0;
// return mnt.toString();
// }
//
// }
| import org.esupportail.papercut.dao.PayPapercutTransactionLogRepository;
import org.esupportail.papercut.domain.PayPapercutTransactionLog;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; | /**
* Licensed to ESUP-Portail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* ESUP-Portail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.services;
@Service
public class AnonymizeOneService {
@Resource
PayPapercutTransactionLogRepository payPapercutTransactionLogRepository;
@Transactional
public void anonymize(long id) { | // Path: src/main/java/org/esupportail/papercut/dao/PayPapercutTransactionLogRepository.java
// @Repository
// public interface PayPapercutTransactionLogRepository extends JpaRepository<PayPapercutTransactionLog, Long>{
//
// Long countByUidAndArchived(String uid, Boolean archived);
//
// List<PayPapercutTransactionLog> findAllByTransactionDateBeforeAndUidIsNotLike(Date oldDate, String uid);
//
// Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByIdtransAndPayMode(String idTrans, PayMode payMode, Pageable pageable);
//
// Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByUid(String uid, Pageable pageable);
//
// Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByUidAndArchived(String uid, Boolean archived, Pageable pageable);
//
// }
//
// Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// @Entity
// @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "papercutContext", type = "string")})
// @Filter(name = "contextFilter", condition = "papercut_context = :papercutContext")
// public class PayPapercutTransactionLog implements ContextSupport {
//
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Temporal(TemporalType.TIMESTAMP)
// @DateTimeFormat(style = "dd/MM/yyyy-HH:mm:ss")
// private Date transactionDate;
//
// @Enumerated(EnumType.STRING)
// private PayMode payMode;
//
// private String uid;
//
// private String papercutContext;
//
// private String reference;
//
// private Integer montant;
//
// private String papercutNewSolde;
//
// private String idtrans;
//
// private String papercutOldSolde;
//
// private Boolean archived = false;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Date getTransactionDate() {
// return transactionDate;
// }
//
// public void setTransactionDate(Date transactionDate) {
// this.transactionDate = transactionDate;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getPapercutContext() {
// return papercutContext;
// }
//
// public void setPapercutContext(String papercutContext) {
// this.papercutContext = papercutContext;
// }
//
// public PayMode getPayMode() {
// return payMode;
// }
//
// public void setPayMode(PayMode payMode) {
// this.payMode = payMode;
// }
//
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public Integer getMontant() {
// return montant;
// }
//
// public void setMontant(Integer montant) {
// this.montant = montant;
// }
//
// public String getPapercutNewSolde() {
// return papercutNewSolde;
// }
//
// public void setPapercutNewSolde(String papercutNewSolde) {
// this.papercutNewSolde = papercutNewSolde;
// }
//
// public String getIdtrans() {
// return idtrans;
// }
//
// public void setIdtrans(String idtrans) {
// this.idtrans = idtrans;
// }
//
// public String getPapercutOldSolde() {
// return papercutOldSolde;
// }
//
// public void setPapercutOldSolde(String papercutOldSolde) {
// this.papercutOldSolde = papercutOldSolde;
// }
//
// public Boolean getArchived() {
// return archived;
// }
//
// public void setArchived(Boolean archived) {
// this.archived = archived;
// }
//
// public String getMontantDevise() {
// Double mnt = new Double(montant)/100.0;
// return mnt.toString();
// }
//
// }
// Path: src/main/java/org/esupportail/papercut/services/AnonymizeOneService.java
import org.esupportail.papercut.dao.PayPapercutTransactionLogRepository;
import org.esupportail.papercut.domain.PayPapercutTransactionLog;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
/**
* Licensed to ESUP-Portail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* ESUP-Portail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.services;
@Service
public class AnonymizeOneService {
@Resource
PayPapercutTransactionLogRepository payPapercutTransactionLogRepository;
@Transactional
public void anonymize(long id) { | PayPapercutTransactionLog transactionLog = payPapercutTransactionLogRepository.findById(id).get(); |
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/config/RestConfig.java | // Path: src/main/java/org/esupportail/papercut/services/RequestResponseLoggingInterceptor.java
// public class RequestResponseLoggingInterceptor implements ClientHttpRequestInterceptor {
//
// private final Logger log = LoggerFactory.getLogger(this.getClass());
//
// @Override
// public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
// logRequest(request, body);
// ClientHttpResponse response = execution.execute(request, body);
// logResponse(response);
// return response;
// }
//
// private void logRequest(HttpRequest request, byte[] body) throws IOException {
// if (log.isDebugEnabled()) {
// log.debug("===========================request begin================================================");
// log.debug("URI : {}", request.getURI());
// log.debug("Method : {}", request.getMethod());
// log.debug("Headers : {}", request.getHeaders());
// log.debug("Request body: {}", new String(body, "UTF-8"));
// log.debug("==========================request end================================================");
// }
// }
//
// private void logResponse(ClientHttpResponse response) throws IOException {
// if (log.isDebugEnabled()) {
// log.debug("============================response begin==========================================");
// log.debug("Status code : {}", response.getStatusCode());
// log.debug("Status text : {}", response.getStatusText());
// log.debug("Headers : {}", response.getHeaders());
// log.debug("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset()));
// log.debug("=======================response end=================================================");
// }
// }
// }
| import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Collections;
import org.esupportail.papercut.services.RequestResponseLoggingInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.BufferingClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.filter.CommonsRequestLoggingFilter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.fasterxml.jackson.databind.DeserializationFeature;
| /**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.config;
@Configuration
public class RestConfig implements WebMvcConfigurer {
@Bean
public ObjectMapper objectMapper() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper;
}
@Bean
public MappingJackson2HttpMessageConverter jacksonConverter() throws Exception {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setObjectMapper(objectMapper());
return converter;
}
@Bean
public RestTemplate restTemplate() throws Exception {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
RestTemplate restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(requestFactory));
| // Path: src/main/java/org/esupportail/papercut/services/RequestResponseLoggingInterceptor.java
// public class RequestResponseLoggingInterceptor implements ClientHttpRequestInterceptor {
//
// private final Logger log = LoggerFactory.getLogger(this.getClass());
//
// @Override
// public ClientHttpResponse intercept(HttpRequest request, byte[] body, ClientHttpRequestExecution execution) throws IOException {
// logRequest(request, body);
// ClientHttpResponse response = execution.execute(request, body);
// logResponse(response);
// return response;
// }
//
// private void logRequest(HttpRequest request, byte[] body) throws IOException {
// if (log.isDebugEnabled()) {
// log.debug("===========================request begin================================================");
// log.debug("URI : {}", request.getURI());
// log.debug("Method : {}", request.getMethod());
// log.debug("Headers : {}", request.getHeaders());
// log.debug("Request body: {}", new String(body, "UTF-8"));
// log.debug("==========================request end================================================");
// }
// }
//
// private void logResponse(ClientHttpResponse response) throws IOException {
// if (log.isDebugEnabled()) {
// log.debug("============================response begin==========================================");
// log.debug("Status code : {}", response.getStatusCode());
// log.debug("Status text : {}", response.getStatusText());
// log.debug("Headers : {}", response.getHeaders());
// log.debug("Response body: {}", StreamUtils.copyToString(response.getBody(), Charset.defaultCharset()));
// log.debug("=======================response end=================================================");
// }
// }
// }
// Path: src/main/java/org/esupportail/papercut/config/RestConfig.java
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Collections;
import org.esupportail.papercut.services.RequestResponseLoggingInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.BufferingClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.filter.CommonsRequestLoggingFilter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import com.fasterxml.jackson.databind.DeserializationFeature;
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.config;
@Configuration
public class RestConfig implements WebMvcConfigurer {
@Bean
public ObjectMapper objectMapper() throws Exception {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
return mapper;
}
@Bean
public MappingJackson2HttpMessageConverter jacksonConverter() throws Exception {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
converter.setObjectMapper(objectMapper());
return converter;
}
@Bean
public RestTemplate restTemplate() throws Exception {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
RestTemplate restTemplate = new RestTemplate(new BufferingClientHttpRequestFactory(requestFactory));
| restTemplate.setInterceptors(Collections.singletonList(new RequestResponseLoggingInterceptor()));
|
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/config/WebConfig.java | // Path: src/main/java/org/esupportail/papercut/web/WebInterceptor.java
// public class WebInterceptor extends HandlerInterceptorAdapter {
//
// @Resource
// EsupPapercutConfig config;
//
// @Resource
// EsupPaperCutService esupPaperCutService;
//
// @Override
// public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
// ModelAndView modelAndView) throws Exception {
//
// String context = WebUtils.getContext(request);
//
// if("webjars".equals(context) || "resources".equals(context)) {
// super.postHandle(request, response, handler, modelAndView);
// } else {
//
// ContextHelper.setCurrentContext(context);
//
// super.postHandle(request, response, handler, modelAndView);
//
// if (modelAndView != null) {
// boolean isViewObject = modelAndView.getView() == null;
// boolean isRedirectView = !isViewObject && modelAndView.getView() instanceof RedirectView;
// boolean viewNameStartsWithRedirect = isViewObject && modelAndView.getViewName().startsWith(UrlBasedViewResolver.REDIRECT_URL_PREFIX);
//
// if (!isRedirectView && !viewNameStartsWithRedirect && context != null) {
// EsupPapercutContext configContext = config.getContext(context);
// if (configContext != null) {
// modelAndView.addObject("title", configContext.getTitle());
// modelAndView.addObject("htmlFooter", configContext.getHtmlFooter());
// modelAndView.addObject("pContext", context);
// }
// modelAndView.addObject("isAdmin", WebUtils.isAdmin());
// modelAndView.addObject("isManager", WebUtils.isManager());
// modelAndView.addObject("availableContexts", WebUtils.availableContexts());
// modelAndView.addObject("payAvailable", !esupPaperCutService.getPayModes(configContext).isEmpty());
// }
// }
// }
//
// }
//
// }
| import org.esupportail.papercut.web.WebInterceptor;
import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.thymeleaf.dialect.springdata.SpringDataDialect;
| /**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.config;
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Bean
| // Path: src/main/java/org/esupportail/papercut/web/WebInterceptor.java
// public class WebInterceptor extends HandlerInterceptorAdapter {
//
// @Resource
// EsupPapercutConfig config;
//
// @Resource
// EsupPaperCutService esupPaperCutService;
//
// @Override
// public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
// ModelAndView modelAndView) throws Exception {
//
// String context = WebUtils.getContext(request);
//
// if("webjars".equals(context) || "resources".equals(context)) {
// super.postHandle(request, response, handler, modelAndView);
// } else {
//
// ContextHelper.setCurrentContext(context);
//
// super.postHandle(request, response, handler, modelAndView);
//
// if (modelAndView != null) {
// boolean isViewObject = modelAndView.getView() == null;
// boolean isRedirectView = !isViewObject && modelAndView.getView() instanceof RedirectView;
// boolean viewNameStartsWithRedirect = isViewObject && modelAndView.getViewName().startsWith(UrlBasedViewResolver.REDIRECT_URL_PREFIX);
//
// if (!isRedirectView && !viewNameStartsWithRedirect && context != null) {
// EsupPapercutContext configContext = config.getContext(context);
// if (configContext != null) {
// modelAndView.addObject("title", configContext.getTitle());
// modelAndView.addObject("htmlFooter", configContext.getHtmlFooter());
// modelAndView.addObject("pContext", context);
// }
// modelAndView.addObject("isAdmin", WebUtils.isAdmin());
// modelAndView.addObject("isManager", WebUtils.isManager());
// modelAndView.addObject("availableContexts", WebUtils.availableContexts());
// modelAndView.addObject("payAvailable", !esupPaperCutService.getPayModes(configContext).isEmpty());
// }
// }
// }
//
// }
//
// }
// Path: src/main/java/org/esupportail/papercut/config/WebConfig.java
import org.esupportail.papercut.web.WebInterceptor;
import org.springframework.boot.autoconfigure.web.ErrorProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.thymeleaf.dialect.springdata.SpringDataDialect;
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.config;
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Bean
| public WebInterceptor webInterceptor() {
|
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/dao/PayPapercutTransactionLogRepository.java | // Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// @Entity
// @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "papercutContext", type = "string")})
// @Filter(name = "contextFilter", condition = "papercut_context = :papercutContext")
// public class PayPapercutTransactionLog implements ContextSupport {
//
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Temporal(TemporalType.TIMESTAMP)
// @DateTimeFormat(style = "dd/MM/yyyy-HH:mm:ss")
// private Date transactionDate;
//
// @Enumerated(EnumType.STRING)
// private PayMode payMode;
//
// private String uid;
//
// private String papercutContext;
//
// private String reference;
//
// private Integer montant;
//
// private String papercutNewSolde;
//
// private String idtrans;
//
// private String papercutOldSolde;
//
// private Boolean archived = false;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Date getTransactionDate() {
// return transactionDate;
// }
//
// public void setTransactionDate(Date transactionDate) {
// this.transactionDate = transactionDate;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getPapercutContext() {
// return papercutContext;
// }
//
// public void setPapercutContext(String papercutContext) {
// this.papercutContext = papercutContext;
// }
//
// public PayMode getPayMode() {
// return payMode;
// }
//
// public void setPayMode(PayMode payMode) {
// this.payMode = payMode;
// }
//
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public Integer getMontant() {
// return montant;
// }
//
// public void setMontant(Integer montant) {
// this.montant = montant;
// }
//
// public String getPapercutNewSolde() {
// return papercutNewSolde;
// }
//
// public void setPapercutNewSolde(String papercutNewSolde) {
// this.papercutNewSolde = papercutNewSolde;
// }
//
// public String getIdtrans() {
// return idtrans;
// }
//
// public void setIdtrans(String idtrans) {
// this.idtrans = idtrans;
// }
//
// public String getPapercutOldSolde() {
// return papercutOldSolde;
// }
//
// public void setPapercutOldSolde(String papercutOldSolde) {
// this.papercutOldSolde = papercutOldSolde;
// }
//
// public Boolean getArchived() {
// return archived;
// }
//
// public void setArchived(Boolean archived) {
// this.archived = archived;
// }
//
// public String getMontantDevise() {
// Double mnt = new Double(montant)/100.0;
// return mnt.toString();
// }
//
// }
//
// Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
| import org.esupportail.papercut.domain.PayPapercutTransactionLog;
import org.esupportail.papercut.domain.PayPapercutTransactionLog.PayMode;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List; | /**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.dao;
@Repository
public interface PayPapercutTransactionLogRepository extends JpaRepository<PayPapercutTransactionLog, Long>{
Long countByUidAndArchived(String uid, Boolean archived);
List<PayPapercutTransactionLog> findAllByTransactionDateBeforeAndUidIsNotLike(Date oldDate, String uid);
| // Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// @Entity
// @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "papercutContext", type = "string")})
// @Filter(name = "contextFilter", condition = "papercut_context = :papercutContext")
// public class PayPapercutTransactionLog implements ContextSupport {
//
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Temporal(TemporalType.TIMESTAMP)
// @DateTimeFormat(style = "dd/MM/yyyy-HH:mm:ss")
// private Date transactionDate;
//
// @Enumerated(EnumType.STRING)
// private PayMode payMode;
//
// private String uid;
//
// private String papercutContext;
//
// private String reference;
//
// private Integer montant;
//
// private String papercutNewSolde;
//
// private String idtrans;
//
// private String papercutOldSolde;
//
// private Boolean archived = false;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Date getTransactionDate() {
// return transactionDate;
// }
//
// public void setTransactionDate(Date transactionDate) {
// this.transactionDate = transactionDate;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getPapercutContext() {
// return papercutContext;
// }
//
// public void setPapercutContext(String papercutContext) {
// this.papercutContext = papercutContext;
// }
//
// public PayMode getPayMode() {
// return payMode;
// }
//
// public void setPayMode(PayMode payMode) {
// this.payMode = payMode;
// }
//
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public Integer getMontant() {
// return montant;
// }
//
// public void setMontant(Integer montant) {
// this.montant = montant;
// }
//
// public String getPapercutNewSolde() {
// return papercutNewSolde;
// }
//
// public void setPapercutNewSolde(String papercutNewSolde) {
// this.papercutNewSolde = papercutNewSolde;
// }
//
// public String getIdtrans() {
// return idtrans;
// }
//
// public void setIdtrans(String idtrans) {
// this.idtrans = idtrans;
// }
//
// public String getPapercutOldSolde() {
// return papercutOldSolde;
// }
//
// public void setPapercutOldSolde(String papercutOldSolde) {
// this.papercutOldSolde = papercutOldSolde;
// }
//
// public Boolean getArchived() {
// return archived;
// }
//
// public void setArchived(Boolean archived) {
// this.archived = archived;
// }
//
// public String getMontantDevise() {
// Double mnt = new Double(montant)/100.0;
// return mnt.toString();
// }
//
// }
//
// Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
// Path: src/main/java/org/esupportail/papercut/dao/PayPapercutTransactionLogRepository.java
import org.esupportail.papercut.domain.PayPapercutTransactionLog;
import org.esupportail.papercut.domain.PayPapercutTransactionLog.PayMode;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.dao;
@Repository
public interface PayPapercutTransactionLogRepository extends JpaRepository<PayPapercutTransactionLog, Long>{
Long countByUidAndArchived(String uid, Boolean archived);
List<PayPapercutTransactionLog> findAllByTransactionDateBeforeAndUidIsNotLike(Date oldDate, String uid);
| Page<PayPapercutTransactionLog> findPayPapercutTransactionLogsByIdtransAndPayMode(String idTrans, PayMode payMode, Pageable pageable); |
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/dao/PapercutDaoServiceAspect.java | // Path: src/main/java/org/esupportail/papercut/security/ContextHelper.java
// public class ContextHelper {
//
// private static ThreadLocal<String> currentContext = new ThreadLocal<>();
//
// public static String getCurrentContext() {
// return currentContext.get();
// }
//
// public static void setCurrentContext(String context) {
// currentContext.set(context);
// }
//
// public static void clear() {
// currentContext.set(null);
// }
//
// }
| import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.esupportail.papercut.security.ContextHelper;
import org.hibernate.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; | /**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.dao;
@Aspect
@Component
public class PapercutDaoServiceAspect {
private final Logger log = LoggerFactory.getLogger(getClass());
// Attention, ne fonctionne pas sur les native query ...
// De même cf doc hibernate "Filters apply to entity queries, but not to direct fetching."
@Before("execution(* org.esupportail.papercut.dao.PapercutDaoService.*(..)) && target(papercutDaoService)")
public void aroundExecution(JoinPoint pjp, PapercutDaoService papercutDaoService) throws Throwable {
org.hibernate.Filter filter = papercutDaoService.entityManager.unwrap(Session.class).enableFilter("contextFilter"); | // Path: src/main/java/org/esupportail/papercut/security/ContextHelper.java
// public class ContextHelper {
//
// private static ThreadLocal<String> currentContext = new ThreadLocal<>();
//
// public static String getCurrentContext() {
// return currentContext.get();
// }
//
// public static void setCurrentContext(String context) {
// currentContext.set(context);
// }
//
// public static void clear() {
// currentContext.set(null);
// }
//
// }
// Path: src/main/java/org/esupportail/papercut/dao/PapercutDaoServiceAspect.java
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.esupportail.papercut.security.ContextHelper;
import org.hibernate.Session;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.dao;
@Aspect
@Component
public class PapercutDaoServiceAspect {
private final Logger log = LoggerFactory.getLogger(getClass());
// Attention, ne fonctionne pas sur les native query ...
// De même cf doc hibernate "Filters apply to entity queries, but not to direct fetching."
@Before("execution(* org.esupportail.papercut.dao.PapercutDaoService.*(..)) && target(papercutDaoService)")
public void aroundExecution(JoinPoint pjp, PapercutDaoService papercutDaoService) throws Throwable {
org.hibernate.Filter filter = papercutDaoService.entityManager.unwrap(Session.class).enableFilter("contextFilter"); | filter.setParameter("papercutContext", ContextHelper.getCurrentContext()); |
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/security/ContextFilter.java | // Path: src/main/java/org/esupportail/papercut/web/WebUtils.java
// public class WebUtils {
//
// public static String getContext(HttpServletRequest request) {
// String path = request.getServletPath();
// if("/error".equals(path)) {
// path = (String)request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);
// }
// String papercutContext = path.replaceFirst("/([^/]*).*", "$1");
// return papercutContext;
// }
//
// public static List<String> availableContexts() {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// if(auth != null && auth.getPrincipal() instanceof ContextUserDetails) {
// ContextUserDetails userDetails = (ContextUserDetails)auth.getPrincipal();
// return userDetails.getAvailableContexts();
// } else {
// return new ArrayList<String>();
// }
// }
//
// public static boolean isUser() {
// return hasRole("ROLE_USER");
// }
//
// public static boolean isManager() {
// return hasRole("ROLE_MANAGER");
// }
//
// public static boolean isAdmin() {
// return hasRole("ROLE_ADMIN");
// }
//
// private static boolean hasRole(String roleName) {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// return auth!=null && auth.getAuthorities() != null && auth.getAuthorities().contains(new SimpleGrantedAuthority(roleName));
// }
// }
| import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.esupportail.papercut.web.WebUtils;
import org.springframework.stereotype.Component; | /**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.security;
@Component
public class ContextFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest; | // Path: src/main/java/org/esupportail/papercut/web/WebUtils.java
// public class WebUtils {
//
// public static String getContext(HttpServletRequest request) {
// String path = request.getServletPath();
// if("/error".equals(path)) {
// path = (String)request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);
// }
// String papercutContext = path.replaceFirst("/([^/]*).*", "$1");
// return papercutContext;
// }
//
// public static List<String> availableContexts() {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// if(auth != null && auth.getPrincipal() instanceof ContextUserDetails) {
// ContextUserDetails userDetails = (ContextUserDetails)auth.getPrincipal();
// return userDetails.getAvailableContexts();
// } else {
// return new ArrayList<String>();
// }
// }
//
// public static boolean isUser() {
// return hasRole("ROLE_USER");
// }
//
// public static boolean isManager() {
// return hasRole("ROLE_MANAGER");
// }
//
// public static boolean isAdmin() {
// return hasRole("ROLE_ADMIN");
// }
//
// private static boolean hasRole(String roleName) {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// return auth!=null && auth.getAuthorities() != null && auth.getAuthorities().contains(new SimpleGrantedAuthority(roleName));
// }
// }
// Path: src/main/java/org/esupportail/papercut/security/ContextFilter.java
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.esupportail.papercut.web.WebUtils;
import org.springframework.stereotype.Component;
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.security;
@Component
public class ContextFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) servletRequest; | String context = WebUtils.getContext(request); |
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/dao/AllContextPapercutDaoService.java | // Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// @Entity
// @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "papercutContext", type = "string")})
// @Filter(name = "contextFilter", condition = "papercut_context = :papercutContext")
// public class PayPapercutTransactionLog implements ContextSupport {
//
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Temporal(TemporalType.TIMESTAMP)
// @DateTimeFormat(style = "dd/MM/yyyy-HH:mm:ss")
// private Date transactionDate;
//
// @Enumerated(EnumType.STRING)
// private PayMode payMode;
//
// private String uid;
//
// private String papercutContext;
//
// private String reference;
//
// private Integer montant;
//
// private String papercutNewSolde;
//
// private String idtrans;
//
// private String papercutOldSolde;
//
// private Boolean archived = false;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Date getTransactionDate() {
// return transactionDate;
// }
//
// public void setTransactionDate(Date transactionDate) {
// this.transactionDate = transactionDate;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getPapercutContext() {
// return papercutContext;
// }
//
// public void setPapercutContext(String papercutContext) {
// this.papercutContext = papercutContext;
// }
//
// public PayMode getPayMode() {
// return payMode;
// }
//
// public void setPayMode(PayMode payMode) {
// this.payMode = payMode;
// }
//
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public Integer getMontant() {
// return montant;
// }
//
// public void setMontant(Integer montant) {
// this.montant = montant;
// }
//
// public String getPapercutNewSolde() {
// return papercutNewSolde;
// }
//
// public void setPapercutNewSolde(String papercutNewSolde) {
// this.papercutNewSolde = papercutNewSolde;
// }
//
// public String getIdtrans() {
// return idtrans;
// }
//
// public void setIdtrans(String idtrans) {
// this.idtrans = idtrans;
// }
//
// public String getPapercutOldSolde() {
// return papercutOldSolde;
// }
//
// public void setPapercutOldSolde(String papercutOldSolde) {
// this.papercutOldSolde = papercutOldSolde;
// }
//
// public Boolean getArchived() {
// return archived;
// }
//
// public void setArchived(Boolean archived) {
// this.archived = archived;
// }
//
// public String getMontantDevise() {
// Double mnt = new Double(montant)/100.0;
// return mnt.toString();
// }
//
// }
| import org.esupportail.papercut.domain.PayPapercutTransactionLog;
import org.springframework.stereotype.Service;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.time.Duration;
import java.time.Instant;
import java.util.Date;
import java.util.List; | /**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.dao;
@Service
public class AllContextPapercutDaoService {
@PersistenceContext
public EntityManager entityManager;
| // Path: src/main/java/org/esupportail/papercut/domain/PayPapercutTransactionLog.java
// @Entity
// @FilterDef(name = "contextFilter", parameters = {@ParamDef(name = "papercutContext", type = "string")})
// @Filter(name = "contextFilter", condition = "papercut_context = :papercutContext")
// public class PayPapercutTransactionLog implements ContextSupport {
//
// public static enum PayMode {
// IZLYPAY, PAYBOX
// }
//
// @Id
// @GeneratedValue(strategy = GenerationType.AUTO)
// @Column(name = "id")
// private Long id;
//
// @Temporal(TemporalType.TIMESTAMP)
// @DateTimeFormat(style = "dd/MM/yyyy-HH:mm:ss")
// private Date transactionDate;
//
// @Enumerated(EnumType.STRING)
// private PayMode payMode;
//
// private String uid;
//
// private String papercutContext;
//
// private String reference;
//
// private Integer montant;
//
// private String papercutNewSolde;
//
// private String idtrans;
//
// private String papercutOldSolde;
//
// private Boolean archived = false;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Date getTransactionDate() {
// return transactionDate;
// }
//
// public void setTransactionDate(Date transactionDate) {
// this.transactionDate = transactionDate;
// }
//
// public String getUid() {
// return uid;
// }
//
// public void setUid(String uid) {
// this.uid = uid;
// }
//
// public String getPapercutContext() {
// return papercutContext;
// }
//
// public void setPapercutContext(String papercutContext) {
// this.papercutContext = papercutContext;
// }
//
// public PayMode getPayMode() {
// return payMode;
// }
//
// public void setPayMode(PayMode payMode) {
// this.payMode = payMode;
// }
//
// public String getReference() {
// return reference;
// }
//
// public void setReference(String reference) {
// this.reference = reference;
// }
//
// public Integer getMontant() {
// return montant;
// }
//
// public void setMontant(Integer montant) {
// this.montant = montant;
// }
//
// public String getPapercutNewSolde() {
// return papercutNewSolde;
// }
//
// public void setPapercutNewSolde(String papercutNewSolde) {
// this.papercutNewSolde = papercutNewSolde;
// }
//
// public String getIdtrans() {
// return idtrans;
// }
//
// public void setIdtrans(String idtrans) {
// this.idtrans = idtrans;
// }
//
// public String getPapercutOldSolde() {
// return papercutOldSolde;
// }
//
// public void setPapercutOldSolde(String papercutOldSolde) {
// this.papercutOldSolde = papercutOldSolde;
// }
//
// public Boolean getArchived() {
// return archived;
// }
//
// public void setArchived(Boolean archived) {
// this.archived = archived;
// }
//
// public String getMontantDevise() {
// Double mnt = new Double(montant)/100.0;
// return mnt.toString();
// }
//
// }
// Path: src/main/java/org/esupportail/papercut/dao/AllContextPapercutDaoService.java
import org.esupportail.papercut.domain.PayPapercutTransactionLog;
import org.springframework.stereotype.Service;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.time.Duration;
import java.time.Instant;
import java.util.Date;
import java.util.List;
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.dao;
@Service
public class AllContextPapercutDaoService {
@PersistenceContext
public EntityManager entityManager;
| public List<PayPapercutTransactionLog> findOldPayPapercutTransactionLogsNotAnonymised(Long oldDays4transactionsLogs) { |
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/web/IndexController.java | // Path: src/main/java/org/esupportail/papercut/config/EsupPapercutConfig.java
// @Component
// @ConfigurationProperties(prefix="esup")
// @PropertySource(value = "classpath:/esup-papercut.properties", encoding = "UTF-8")
// @EnableGlobalMethodSecurity(prePostEnabled=true)
// public class EsupPapercutConfig {
//
// String defaultContext = null;
//
// Map<String, EsupPapercutContext> contexts;
//
// public Map<String, EsupPapercutContext> getContexts() {
// return contexts;
// }
//
// public void setContexts(Map<String, EsupPapercutContext> contexts) {
// this.contexts = contexts;
// }
//
// public void setDefaultContext(String defaultContext) {
// this.defaultContext = defaultContext;
// }
//
// public String getDefaultContext() {
// List<String> availableContexts = WebUtils.availableContexts();
// if(!availableContexts.isEmpty()) {
// if(defaultContext != null && availableContexts.contains(defaultContext)) {
// return defaultContext;
// } else {
// return availableContexts.get(0);
// }
// }
// return defaultContext;
// }
//
// public EsupPapercutContext getContext(String contextKey) {
// return contexts.get(contextKey);
// }
//
// }
| import javax.annotation.Resource;
import org.esupportail.papercut.config.EsupPapercutConfig;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; | /**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.web;
@Controller
public class IndexController {
@Resource | // Path: src/main/java/org/esupportail/papercut/config/EsupPapercutConfig.java
// @Component
// @ConfigurationProperties(prefix="esup")
// @PropertySource(value = "classpath:/esup-papercut.properties", encoding = "UTF-8")
// @EnableGlobalMethodSecurity(prePostEnabled=true)
// public class EsupPapercutConfig {
//
// String defaultContext = null;
//
// Map<String, EsupPapercutContext> contexts;
//
// public Map<String, EsupPapercutContext> getContexts() {
// return contexts;
// }
//
// public void setContexts(Map<String, EsupPapercutContext> contexts) {
// this.contexts = contexts;
// }
//
// public void setDefaultContext(String defaultContext) {
// this.defaultContext = defaultContext;
// }
//
// public String getDefaultContext() {
// List<String> availableContexts = WebUtils.availableContexts();
// if(!availableContexts.isEmpty()) {
// if(defaultContext != null && availableContexts.contains(defaultContext)) {
// return defaultContext;
// } else {
// return availableContexts.get(0);
// }
// }
// return defaultContext;
// }
//
// public EsupPapercutContext getContext(String contextKey) {
// return contexts.get(contextKey);
// }
//
// }
// Path: src/main/java/org/esupportail/papercut/web/IndexController.java
import javax.annotation.Resource;
import org.esupportail.papercut.config.EsupPapercutConfig;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.web;
@Controller
public class IndexController {
@Resource | EsupPapercutConfig config; |
EsupPortail/esup-papercut | src/main/java/org/esupportail/papercut/config/EsupPapercutConfig.java | // Path: src/main/java/org/esupportail/papercut/web/WebUtils.java
// public class WebUtils {
//
// public static String getContext(HttpServletRequest request) {
// String path = request.getServletPath();
// if("/error".equals(path)) {
// path = (String)request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);
// }
// String papercutContext = path.replaceFirst("/([^/]*).*", "$1");
// return papercutContext;
// }
//
// public static List<String> availableContexts() {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// if(auth != null && auth.getPrincipal() instanceof ContextUserDetails) {
// ContextUserDetails userDetails = (ContextUserDetails)auth.getPrincipal();
// return userDetails.getAvailableContexts();
// } else {
// return new ArrayList<String>();
// }
// }
//
// public static boolean isUser() {
// return hasRole("ROLE_USER");
// }
//
// public static boolean isManager() {
// return hasRole("ROLE_MANAGER");
// }
//
// public static boolean isAdmin() {
// return hasRole("ROLE_ADMIN");
// }
//
// private static boolean hasRole(String roleName) {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// return auth!=null && auth.getAuthorities() != null && auth.getAuthorities().contains(new SimpleGrantedAuthority(roleName));
// }
// }
| import java.util.List;
import java.util.Map;
import org.esupportail.papercut.web.WebUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.stereotype.Component; | /**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.config;
@Component
@ConfigurationProperties(prefix="esup")
@PropertySource(value = "classpath:/esup-papercut.properties", encoding = "UTF-8")
@EnableGlobalMethodSecurity(prePostEnabled=true)
public class EsupPapercutConfig {
String defaultContext = null;
Map<String, EsupPapercutContext> contexts;
public Map<String, EsupPapercutContext> getContexts() {
return contexts;
}
public void setContexts(Map<String, EsupPapercutContext> contexts) {
this.contexts = contexts;
}
public void setDefaultContext(String defaultContext) {
this.defaultContext = defaultContext;
}
public String getDefaultContext() { | // Path: src/main/java/org/esupportail/papercut/web/WebUtils.java
// public class WebUtils {
//
// public static String getContext(HttpServletRequest request) {
// String path = request.getServletPath();
// if("/error".equals(path)) {
// path = (String)request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);
// }
// String papercutContext = path.replaceFirst("/([^/]*).*", "$1");
// return papercutContext;
// }
//
// public static List<String> availableContexts() {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// if(auth != null && auth.getPrincipal() instanceof ContextUserDetails) {
// ContextUserDetails userDetails = (ContextUserDetails)auth.getPrincipal();
// return userDetails.getAvailableContexts();
// } else {
// return new ArrayList<String>();
// }
// }
//
// public static boolean isUser() {
// return hasRole("ROLE_USER");
// }
//
// public static boolean isManager() {
// return hasRole("ROLE_MANAGER");
// }
//
// public static boolean isAdmin() {
// return hasRole("ROLE_ADMIN");
// }
//
// private static boolean hasRole(String roleName) {
// Authentication auth = SecurityContextHolder.getContext().getAuthentication();
// return auth!=null && auth.getAuthorities() != null && auth.getAuthorities().contains(new SimpleGrantedAuthority(roleName));
// }
// }
// Path: src/main/java/org/esupportail/papercut/config/EsupPapercutConfig.java
import java.util.List;
import java.util.Map;
import org.esupportail.papercut.web.WebUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.stereotype.Component;
/**
* Licensed to EsupPortail under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* EsupPortail licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.esupportail.papercut.config;
@Component
@ConfigurationProperties(prefix="esup")
@PropertySource(value = "classpath:/esup-papercut.properties", encoding = "UTF-8")
@EnableGlobalMethodSecurity(prePostEnabled=true)
public class EsupPapercutConfig {
String defaultContext = null;
Map<String, EsupPapercutContext> contexts;
public Map<String, EsupPapercutContext> getContexts() {
return contexts;
}
public void setContexts(Map<String, EsupPapercutContext> contexts) {
this.contexts = contexts;
}
public void setDefaultContext(String defaultContext) {
this.defaultContext = defaultContext;
}
public String getDefaultContext() { | List<String> availableContexts = WebUtils.availableContexts(); |
CCob/bittrex4j | src/test/java/com/github/ccob/bittrex4j/BittrexExchangeTest.java | // Path: src/main/java/com/github/ccob/bittrex4j/dao/OrderBook.java
// public enum TYPE {
// buy, sell, both;
// }
| import com.github.ccob.bittrex4j.dao.*;
import com.github.ccob.bittrex4j.dao.OrderBook.TYPE;
import com.github.signalr4j.client.hubs.*;
import com.google.gson.Gson;
import com.google.gson.internal.LinkedTreeMap;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.ProtocolVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.entity.BasicHttpEntity;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.message.BasicStatusLine;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.mockito.runners.MockitoJUnitRunner;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Scanner;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.*;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; | @Test
public void shouldReturnTicker() throws IOException{
setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/Ticker.json"));
Response<Ticker> result = bittrexExchange.getTicker("ANY");
assertThat(result.isSuccess(), is(true));
assertEquals(0, new BigDecimal("0.0483").compareTo(result.getResult().getAsk()));
}
@Test
public void shouldReturnMarketSummaries() throws IOException{
setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/MarketSummaries.json"));
Response<MarketSummaryResult[]> result = bittrexExchange.getMarketSummaries();
assertThat(result.isSuccess(), is(true));
assertThat(result.getResult().length,equalTo(263));
}
@Test
public void shouldReturnMarketSummary() throws IOException{
setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/MarketSummary.json"));
Response<MarketSummary> result = bittrexExchange.getMarketSummary("ANY");
assertThat(result.isSuccess(), is(true));
assertThat(result.getResult().getMarketName(), equalTo("BTC-ETH"));
}
@Test
public void shouldReturnOrderBook() throws IOException{
setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/OrderBook.json")); | // Path: src/main/java/com/github/ccob/bittrex4j/dao/OrderBook.java
// public enum TYPE {
// buy, sell, both;
// }
// Path: src/test/java/com/github/ccob/bittrex4j/BittrexExchangeTest.java
import com.github.ccob.bittrex4j.dao.*;
import com.github.ccob.bittrex4j.dao.OrderBook.TYPE;
import com.github.signalr4j.client.hubs.*;
import com.google.gson.Gson;
import com.google.gson.internal.LinkedTreeMap;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.ProtocolVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.entity.BasicHttpEntity;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.message.BasicStatusLine;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.*;
import org.mockito.runners.MockitoJUnitRunner;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Scanner;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.*;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@Test
public void shouldReturnTicker() throws IOException{
setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/Ticker.json"));
Response<Ticker> result = bittrexExchange.getTicker("ANY");
assertThat(result.isSuccess(), is(true));
assertEquals(0, new BigDecimal("0.0483").compareTo(result.getResult().getAsk()));
}
@Test
public void shouldReturnMarketSummaries() throws IOException{
setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/MarketSummaries.json"));
Response<MarketSummaryResult[]> result = bittrexExchange.getMarketSummaries();
assertThat(result.isSuccess(), is(true));
assertThat(result.getResult().length,equalTo(263));
}
@Test
public void shouldReturnMarketSummary() throws IOException{
setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/MarketSummary.json"));
Response<MarketSummary> result = bittrexExchange.getMarketSummary("ANY");
assertThat(result.isSuccess(), is(true));
assertThat(result.getResult().getMarketName(), equalTo("BTC-ETH"));
}
@Test
public void shouldReturnOrderBook() throws IOException{
setExpectationForJsonResultOnWebAPICall(loadTestResourceAsString("/OrderBook.json")); | Response<OrderBook> result = (Response<OrderBook>) bittrexExchange.getOrderBook("ANY", TYPE.both); |
CCob/bittrex4j | src/main/java/com/github/ccob/bittrex4j/cloudflare/CloudFlareAuthorizer.java | // Path: src/main/java/com/github/ccob/bittrex4j/PatternStreamer.java
// public final class PatternStreamer {
// private final Pattern pattern;
// public PatternStreamer(String regex) {
// this.pattern = Pattern.compile(regex);
// }
// public PatternStreamer(Pattern regex){
// this.pattern=regex;
// }
// public Stream<String> results(CharSequence input) {
// List<String> list = new ArrayList<>();
// for (Matcher m = this.pattern.matcher(input); m.find(); )
// for(int idx = 1; idx<=m.groupCount(); ++idx){
// list.add(m.group(idx));
// }
// return list.stream();
// }
// }
//
// Path: src/main/java/com/github/ccob/bittrex4j/Utils.java
// public class Utils {
//
// public static String convertStreamToString(InputStream is) {
// java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
// return s.hasNext() ? s.next() : "";
// }
//
// public static String getUserAgent() {
// if (BittrexExchange.class.getPackage().getImplementationVersion() != null) {
// return "bittrex4j/" + BittrexExchange.class.getPackage().getImplementationVersion();
// } else {
// return "bittrex4j/1.x";
// }
// }
// }
| import com.github.ccob.bittrex4j.PatternStreamer;
import com.github.ccob.bittrex4j.Utils;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.cookie.Cookie;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | private int httpStatus;
private String responseText;
Response(int httpStatus, String responseText) {
this.httpStatus = httpStatus;
this.responseText = responseText;
}
}
public CloudFlareAuthorizer(HttpClient httpClient, HttpClientContext httpClientContext) {
this.httpClient = httpClient;
this.httpClientContext = httpClientContext;
}
public boolean getAuthorizationResult(String url) throws IOException, ScriptException {
URL cloudFlareUrl = new URL(url);
try {
int retries = 5;
int timer = 4500;
Response response = getResponse(url,url);
while (response.httpStatus == HttpStatus.SC_SERVICE_UNAVAILABLE && retries-- > 0) {
log.trace("CloudFlare response HTML:");
log.trace(response.responseText);
String answer = getJsAnswer(cloudFlareUrl,response.responseText); | // Path: src/main/java/com/github/ccob/bittrex4j/PatternStreamer.java
// public final class PatternStreamer {
// private final Pattern pattern;
// public PatternStreamer(String regex) {
// this.pattern = Pattern.compile(regex);
// }
// public PatternStreamer(Pattern regex){
// this.pattern=regex;
// }
// public Stream<String> results(CharSequence input) {
// List<String> list = new ArrayList<>();
// for (Matcher m = this.pattern.matcher(input); m.find(); )
// for(int idx = 1; idx<=m.groupCount(); ++idx){
// list.add(m.group(idx));
// }
// return list.stream();
// }
// }
//
// Path: src/main/java/com/github/ccob/bittrex4j/Utils.java
// public class Utils {
//
// public static String convertStreamToString(InputStream is) {
// java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
// return s.hasNext() ? s.next() : "";
// }
//
// public static String getUserAgent() {
// if (BittrexExchange.class.getPackage().getImplementationVersion() != null) {
// return "bittrex4j/" + BittrexExchange.class.getPackage().getImplementationVersion();
// } else {
// return "bittrex4j/1.x";
// }
// }
// }
// Path: src/main/java/com/github/ccob/bittrex4j/cloudflare/CloudFlareAuthorizer.java
import com.github.ccob.bittrex4j.PatternStreamer;
import com.github.ccob.bittrex4j.Utils;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.cookie.Cookie;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
private int httpStatus;
private String responseText;
Response(int httpStatus, String responseText) {
this.httpStatus = httpStatus;
this.responseText = responseText;
}
}
public CloudFlareAuthorizer(HttpClient httpClient, HttpClientContext httpClientContext) {
this.httpClient = httpClient;
this.httpClientContext = httpClientContext;
}
public boolean getAuthorizationResult(String url) throws IOException, ScriptException {
URL cloudFlareUrl = new URL(url);
try {
int retries = 5;
int timer = 4500;
Response response = getResponse(url,url);
while (response.httpStatus == HttpStatus.SC_SERVICE_UNAVAILABLE && retries-- > 0) {
log.trace("CloudFlare response HTML:");
log.trace(response.responseText);
String answer = getJsAnswer(cloudFlareUrl,response.responseText); | String jschl_vc = new PatternStreamer(jsChallenge).results(response.responseText).findFirst().orElse(""); |
CCob/bittrex4j | src/main/java/com/github/ccob/bittrex4j/cloudflare/CloudFlareAuthorizer.java | // Path: src/main/java/com/github/ccob/bittrex4j/PatternStreamer.java
// public final class PatternStreamer {
// private final Pattern pattern;
// public PatternStreamer(String regex) {
// this.pattern = Pattern.compile(regex);
// }
// public PatternStreamer(Pattern regex){
// this.pattern=regex;
// }
// public Stream<String> results(CharSequence input) {
// List<String> list = new ArrayList<>();
// for (Matcher m = this.pattern.matcher(input); m.find(); )
// for(int idx = 1; idx<=m.groupCount(); ++idx){
// list.add(m.group(idx));
// }
// return list.stream();
// }
// }
//
// Path: src/main/java/com/github/ccob/bittrex4j/Utils.java
// public class Utils {
//
// public static String convertStreamToString(InputStream is) {
// java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
// return s.hasNext() ? s.next() : "";
// }
//
// public static String getUserAgent() {
// if (BittrexExchange.class.getPackage().getImplementationVersion() != null) {
// return "bittrex4j/" + BittrexExchange.class.getPackage().getImplementationVersion();
// } else {
// return "bittrex4j/1.x";
// }
// }
// }
| import com.github.ccob.bittrex4j.PatternStreamer;
import com.github.ccob.bittrex4j.Utils;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.cookie.Cookie;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | .findFirst();
if(cfClearanceCookie.isPresent()) {
log.info("Cloudflare DDos authorization success, cf_clearance: {}",
cfClearanceCookie.get().getValue());
}else{
log.info("Cloudflare DDoS is not currently active");
}
return true;
}
private Response getResponse(String url, String referer) throws IOException {
HttpGet getRequest = new HttpGet(url);
if(referer != null)
getRequest.setHeader(HttpHeaders.REFERER,referer);
int hardTimeout = 30; // seconds
TimerTask task = new TimerTask() {
@Override
public void run() {
getRequest.abort();
}
};
new Timer(true).schedule(task, hardTimeout * 1000);
HttpResponse httpResponse = httpClient.execute(getRequest,httpClientContext);
| // Path: src/main/java/com/github/ccob/bittrex4j/PatternStreamer.java
// public final class PatternStreamer {
// private final Pattern pattern;
// public PatternStreamer(String regex) {
// this.pattern = Pattern.compile(regex);
// }
// public PatternStreamer(Pattern regex){
// this.pattern=regex;
// }
// public Stream<String> results(CharSequence input) {
// List<String> list = new ArrayList<>();
// for (Matcher m = this.pattern.matcher(input); m.find(); )
// for(int idx = 1; idx<=m.groupCount(); ++idx){
// list.add(m.group(idx));
// }
// return list.stream();
// }
// }
//
// Path: src/main/java/com/github/ccob/bittrex4j/Utils.java
// public class Utils {
//
// public static String convertStreamToString(InputStream is) {
// java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
// return s.hasNext() ? s.next() : "";
// }
//
// public static String getUserAgent() {
// if (BittrexExchange.class.getPackage().getImplementationVersion() != null) {
// return "bittrex4j/" + BittrexExchange.class.getPackage().getImplementationVersion();
// } else {
// return "bittrex4j/1.x";
// }
// }
// }
// Path: src/main/java/com/github/ccob/bittrex4j/cloudflare/CloudFlareAuthorizer.java
import com.github.ccob.bittrex4j.PatternStreamer;
import com.github.ccob.bittrex4j.Utils;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.cookie.Cookie;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Optional;
import java.util.Timer;
import java.util.TimerTask;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
.findFirst();
if(cfClearanceCookie.isPresent()) {
log.info("Cloudflare DDos authorization success, cf_clearance: {}",
cfClearanceCookie.get().getValue());
}else{
log.info("Cloudflare DDoS is not currently active");
}
return true;
}
private Response getResponse(String url, String referer) throws IOException {
HttpGet getRequest = new HttpGet(url);
if(referer != null)
getRequest.setHeader(HttpHeaders.REFERER,referer);
int hardTimeout = 30; // seconds
TimerTask task = new TimerTask() {
@Override
public void run() {
getRequest.abort();
}
};
new Timer(true).schedule(task, hardTimeout * 1000);
HttpResponse httpResponse = httpClient.execute(getRequest,httpClientContext);
| String responseText = Utils.convertStreamToString(httpResponse.getEntity().getContent()); |
CCob/bittrex4j | src/main/java/com/github/ccob/bittrex4j/dao/MarketSummary.java | // Path: src/main/java/com/github/ccob/bittrex4j/DateTimeDeserializer.java
// public class DateTimeDeserializer extends JsonDeserializer<ZonedDateTime> {
//
// @Override
// public ZonedDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
//
// DateTimeFormatter formatter =
// DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss[.SSS]").withZone(ZoneId.of("UTC"));
//
// String value = p.getValueAsString();
// ZonedDateTime result = null;
//
// if(value.matches("[0-9]{12,}")){
// Instant i = Instant.ofEpochMilli(Long.parseLong(value));
// result = ZonedDateTime.ofInstant(i, ZoneId.of("UTC"));
// }else{
//
// if (value != null) {
// int index;
// if ((index = value.indexOf('.')) > -1) {
// char[] chars = new char[4 - (value.length() - index)];
// Arrays.fill(chars, '0');
// value += new String(chars);
// }
// result = ZonedDateTime.from(formatter.parse(value));
// }
// }
//
// return result;
// }
// }
| import com.fasterxml.jackson.annotation.JsonAlias;
import com.github.ccob.bittrex4j.DateTimeDeserializer;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.math.BigDecimal;
import java.time.ZonedDateTime; | /*
* *
* This file is part of the bittrex4j project.
*
* @author CCob
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* /
*/
package com.github.ccob.bittrex4j.dao;
/**
* Created by ceri on 09/09/2017.
*/
@JsonIgnoreProperties("DisplayMarketName")
public class MarketSummary {
@JsonProperty("MarketName")
@JsonAlias("M")
String marketName;
@JsonProperty("High")
@JsonAlias("H")
BigDecimal high;
@JsonProperty("Low")
@JsonAlias("L")
BigDecimal low;
@JsonProperty("Volume")
@JsonAlias("V")
BigDecimal volume;
@JsonProperty("Last")
@JsonAlias("l")
BigDecimal last;
@JsonProperty("BaseVolume")
@JsonAlias("m")
BigDecimal baseVolume;
@JsonProperty("TimeStamp")
@JsonAlias("T") | // Path: src/main/java/com/github/ccob/bittrex4j/DateTimeDeserializer.java
// public class DateTimeDeserializer extends JsonDeserializer<ZonedDateTime> {
//
// @Override
// public ZonedDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
//
// DateTimeFormatter formatter =
// DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss[.SSS]").withZone(ZoneId.of("UTC"));
//
// String value = p.getValueAsString();
// ZonedDateTime result = null;
//
// if(value.matches("[0-9]{12,}")){
// Instant i = Instant.ofEpochMilli(Long.parseLong(value));
// result = ZonedDateTime.ofInstant(i, ZoneId.of("UTC"));
// }else{
//
// if (value != null) {
// int index;
// if ((index = value.indexOf('.')) > -1) {
// char[] chars = new char[4 - (value.length() - index)];
// Arrays.fill(chars, '0');
// value += new String(chars);
// }
// result = ZonedDateTime.from(formatter.parse(value));
// }
// }
//
// return result;
// }
// }
// Path: src/main/java/com/github/ccob/bittrex4j/dao/MarketSummary.java
import com.fasterxml.jackson.annotation.JsonAlias;
import com.github.ccob.bittrex4j.DateTimeDeserializer;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.math.BigDecimal;
import java.time.ZonedDateTime;
/*
* *
* This file is part of the bittrex4j project.
*
* @author CCob
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* /
*/
package com.github.ccob.bittrex4j.dao;
/**
* Created by ceri on 09/09/2017.
*/
@JsonIgnoreProperties("DisplayMarketName")
public class MarketSummary {
@JsonProperty("MarketName")
@JsonAlias("M")
String marketName;
@JsonProperty("High")
@JsonAlias("H")
BigDecimal high;
@JsonProperty("Low")
@JsonAlias("L")
BigDecimal low;
@JsonProperty("Volume")
@JsonAlias("V")
BigDecimal volume;
@JsonProperty("Last")
@JsonAlias("l")
BigDecimal last;
@JsonProperty("BaseVolume")
@JsonAlias("m")
BigDecimal baseVolume;
@JsonProperty("TimeStamp")
@JsonAlias("T") | @JsonDeserialize(using = DateTimeDeserializer.class) |
CCob/bittrex4j | src/test/java/com/github/ccob/bittrex4j/ObservableTest.java | // Path: src/main/java/com/github/ccob/bittrex4j/listeners/Listener.java
// @FunctionalInterface
// public interface Listener<EventType> {
// void onEvent(EventType eventType);
// }
| import com.github.ccob.bittrex4j.listeners.Listener;
import org.junit.Test; | package com.github.ccob.bittrex4j;
public class ObservableTest {
@Test(expected = IllegalArgumentException.class)
public void shouldThrowWhenAddingNullObserver() throws Exception {
Observable<Object> observable = new Observable<>();
observable.addObserver(null);
}
@Test
public void shouldAllowSameObserverTwice() throws Exception {
Observable<Object> observable = new Observable<>(); | // Path: src/main/java/com/github/ccob/bittrex4j/listeners/Listener.java
// @FunctionalInterface
// public interface Listener<EventType> {
// void onEvent(EventType eventType);
// }
// Path: src/test/java/com/github/ccob/bittrex4j/ObservableTest.java
import com.github.ccob.bittrex4j.listeners.Listener;
import org.junit.Test;
package com.github.ccob.bittrex4j;
public class ObservableTest {
@Test(expected = IllegalArgumentException.class)
public void shouldThrowWhenAddingNullObserver() throws Exception {
Observable<Object> observable = new Observable<>();
observable.addObserver(null);
}
@Test
public void shouldAllowSameObserverTwice() throws Exception {
Observable<Object> observable = new Observable<>(); | Listener<Object> listener = new Listener<Object>() { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/utils/ProjectsAndSettingsEnabledSupport.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/Settings.java
// public class Settings {
//
// @Nonnull
// private final Project _project;
// @Nonnull
// private final GolangSettings _golang;
// @Nonnull
// private final BuildSettings _build;
// @Nonnull
// private final ToolchainSettings _toolchain;
// @Nonnull
// private final DependenciesSettings _dependencies;
// @Nonnull
// private final TestingSettings _testing;
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container) {
// _project = project;
// _golang = container.getByType(GolangSettings.class);
// if (!(_golang instanceof ExtensionAware)) {
// throw new IllegalStateException("golang instance (" + _golang + ") of provided extension container (" + container + ") is not an instance of " + ExtensionAware.class.getName() + ".");
// }
// final ExtensionContainer globalExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = globalExtensions.getByType(BuildSettings.class);
// _toolchain = globalExtensions.getByType(ToolchainSettings.class);
// _dependencies = globalExtensions.getByType(DependenciesSettings.class);
// _testing = globalExtensions.getByType(TestingSettings.class);
// }
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container, boolean init) {
// _project = project;
// _golang = container.create("golang", GolangSettings.class, init, project);
// final ExtensionContainer taskExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = taskExtensions.create("build", BuildSettings.class, init, project);
// _toolchain = taskExtensions.create("toolchain", ToolchainSettings.class, init, project);
// _dependencies = taskExtensions.create("dependencies", DependenciesSettings.class, init, project);
// _testing = taskExtensions.create("testing", TestingSettings.class, init, project);
// }
//
// public Settings(@Nonnull Project project, @Nonnull GolangSettings golang, @Nonnull BuildSettings build, @Nonnull ToolchainSettings toolchain, @Nonnull DependenciesSettings dependencies, @Nonnull TestingSettings testing) {
// _project = project;
// _golang = golang;
// _build = build;
// _toolchain = toolchain;
// _dependencies = dependencies;
// _testing = testing;
// }
//
// @Nonnull
// public GolangSettings getGolang() {
// return _golang;
// }
//
// @Nonnull
// public BuildSettings getBuild() {
// return _build;
// }
//
// @Nonnull
// public ToolchainSettings getToolchain() {
// return _toolchain;
// }
//
// @Nonnull
// public DependenciesSettings getDependencies() {
// return _dependencies;
// }
//
// @Nonnull
// public TestingSettings getTesting() {
// return _testing;
// }
//
// @Nonnull
// public Project getProject() {
// return _project;
// }
//
// @Nonnull
// public Settings merge(@Nonnull Settings... with) {
// final GolangSettings golang = new GolangSettings(false, _project);
// final BuildSettings build = new BuildSettings(false, _project);
// final ToolchainSettings toolchain = new ToolchainSettings(false, _project);
// final DependenciesSettings dependencies = new DependenciesSettings(false, _project);
// final TestingSettings testing = new TestingSettings(false, _project);
//
// copyNonNulls(GolangSettings.class, _golang, golang);
// copyNonNulls(BuildSettings.class, _build, build);
// copyNonNulls(ToolchainSettings.class, _toolchain, toolchain);
// copyNonNulls(DependenciesSettings.class, _dependencies, dependencies);
// copyNonNulls(TestingSettings.class, _testing, testing);
//
// for (final Settings source : with) {
// copyNonNulls(GolangSettings.class, source.getGolang(), golang);
// copyNonNulls(BuildSettings.class, source.getBuild(), build);
// copyNonNulls(ToolchainSettings.class, source.getToolchain(), toolchain);
// copyNonNulls(DependenciesSettings.class, source.getDependencies(), dependencies);
// copyNonNulls(TestingSettings.class, source.getTesting(), testing);
// }
//
// return new Settings(_project, golang, build, toolchain, dependencies, testing);
// }
// }
| import org.echocat.gradle.plugins.golang.model.Settings;
import org.gradle.api.Project;
import javax.annotation.Nonnull; | package org.echocat.gradle.plugins.golang.utils;
public abstract class ProjectsAndSettingsEnabledSupport extends SettingsEnabledSupport {
@Nonnull
private final Project _project;
| // Path: src/main/java/org/echocat/gradle/plugins/golang/model/Settings.java
// public class Settings {
//
// @Nonnull
// private final Project _project;
// @Nonnull
// private final GolangSettings _golang;
// @Nonnull
// private final BuildSettings _build;
// @Nonnull
// private final ToolchainSettings _toolchain;
// @Nonnull
// private final DependenciesSettings _dependencies;
// @Nonnull
// private final TestingSettings _testing;
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container) {
// _project = project;
// _golang = container.getByType(GolangSettings.class);
// if (!(_golang instanceof ExtensionAware)) {
// throw new IllegalStateException("golang instance (" + _golang + ") of provided extension container (" + container + ") is not an instance of " + ExtensionAware.class.getName() + ".");
// }
// final ExtensionContainer globalExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = globalExtensions.getByType(BuildSettings.class);
// _toolchain = globalExtensions.getByType(ToolchainSettings.class);
// _dependencies = globalExtensions.getByType(DependenciesSettings.class);
// _testing = globalExtensions.getByType(TestingSettings.class);
// }
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container, boolean init) {
// _project = project;
// _golang = container.create("golang", GolangSettings.class, init, project);
// final ExtensionContainer taskExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = taskExtensions.create("build", BuildSettings.class, init, project);
// _toolchain = taskExtensions.create("toolchain", ToolchainSettings.class, init, project);
// _dependencies = taskExtensions.create("dependencies", DependenciesSettings.class, init, project);
// _testing = taskExtensions.create("testing", TestingSettings.class, init, project);
// }
//
// public Settings(@Nonnull Project project, @Nonnull GolangSettings golang, @Nonnull BuildSettings build, @Nonnull ToolchainSettings toolchain, @Nonnull DependenciesSettings dependencies, @Nonnull TestingSettings testing) {
// _project = project;
// _golang = golang;
// _build = build;
// _toolchain = toolchain;
// _dependencies = dependencies;
// _testing = testing;
// }
//
// @Nonnull
// public GolangSettings getGolang() {
// return _golang;
// }
//
// @Nonnull
// public BuildSettings getBuild() {
// return _build;
// }
//
// @Nonnull
// public ToolchainSettings getToolchain() {
// return _toolchain;
// }
//
// @Nonnull
// public DependenciesSettings getDependencies() {
// return _dependencies;
// }
//
// @Nonnull
// public TestingSettings getTesting() {
// return _testing;
// }
//
// @Nonnull
// public Project getProject() {
// return _project;
// }
//
// @Nonnull
// public Settings merge(@Nonnull Settings... with) {
// final GolangSettings golang = new GolangSettings(false, _project);
// final BuildSettings build = new BuildSettings(false, _project);
// final ToolchainSettings toolchain = new ToolchainSettings(false, _project);
// final DependenciesSettings dependencies = new DependenciesSettings(false, _project);
// final TestingSettings testing = new TestingSettings(false, _project);
//
// copyNonNulls(GolangSettings.class, _golang, golang);
// copyNonNulls(BuildSettings.class, _build, build);
// copyNonNulls(ToolchainSettings.class, _toolchain, toolchain);
// copyNonNulls(DependenciesSettings.class, _dependencies, dependencies);
// copyNonNulls(TestingSettings.class, _testing, testing);
//
// for (final Settings source : with) {
// copyNonNulls(GolangSettings.class, source.getGolang(), golang);
// copyNonNulls(BuildSettings.class, source.getBuild(), build);
// copyNonNulls(ToolchainSettings.class, source.getToolchain(), toolchain);
// copyNonNulls(DependenciesSettings.class, source.getDependencies(), dependencies);
// copyNonNulls(TestingSettings.class, source.getTesting(), testing);
// }
//
// return new Settings(_project, golang, build, toolchain, dependencies, testing);
// }
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/ProjectsAndSettingsEnabledSupport.java
import org.echocat.gradle.plugins.golang.model.Settings;
import org.gradle.api.Project;
import javax.annotation.Nonnull;
package org.echocat.gradle.plugins.golang.utils;
public abstract class ProjectsAndSettingsEnabledSupport extends SettingsEnabledSupport {
@Nonnull
private final Project _project;
| public ProjectsAndSettingsEnabledSupport(@Nonnull Project project, @Nonnull Settings settings) { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/GolangOrgVcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git; | package org.echocat.gradle.plugins.golang.vcs.isps;
public class GolangOrgVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
private static final Logger LOGGER = LoggerFactory.getLogger(GolangOrgVcsRepositoryProvider.class);
protected static final Pattern REF_PATTERN = compile("^refs/(?:heads|tags)/v(?<version>[0-9]{1,9}(?:\\.[0-9]{1,9}(?:\\.[0-9]{1,9})?)?)$");
public GolangOrgVcsRepositoryProvider() {
super("golang.org/", compile("^(?<root>golang\\.org/x/(?<repo>[A-Za-z0-9_.\\-]+))(?<subPath>/[A-Za-z0-9_.\\-]+)*$"));
}
@Nonnull
@Override | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/GolangOrgVcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
package org.echocat.gradle.plugins.golang.vcs.isps;
public class GolangOrgVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
private static final Logger LOGGER = LoggerFactory.getLogger(GolangOrgVcsRepositoryProvider.class);
protected static final Pattern REF_PATTERN = compile("^refs/(?:heads|tags)/v(?<version>[0-9]{1,9}(?:\\.[0-9]{1,9}(?:\\.[0-9]{1,9})?)?)$");
public GolangOrgVcsRepositoryProvider() {
super("golang.org/", compile("^(?<root>golang\\.org/x/(?<repo>[A-Za-z0-9_.\\-]+))(?<subPath>/[A-Za-z0-9_.\\-]+)*$"));
}
@Nonnull
@Override | protected String rootFor(@Nonnull Matcher matcher, @Nonnull RawVcsReference rawReference) throws VcsException { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/GolangOrgVcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git; | package org.echocat.gradle.plugins.golang.vcs.isps;
public class GolangOrgVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
private static final Logger LOGGER = LoggerFactory.getLogger(GolangOrgVcsRepositoryProvider.class);
protected static final Pattern REF_PATTERN = compile("^refs/(?:heads|tags)/v(?<version>[0-9]{1,9}(?:\\.[0-9]{1,9}(?:\\.[0-9]{1,9})?)?)$");
public GolangOrgVcsRepositoryProvider() {
super("golang.org/", compile("^(?<root>golang\\.org/x/(?<repo>[A-Za-z0-9_.\\-]+))(?<subPath>/[A-Za-z0-9_.\\-]+)*$"));
}
@Nonnull
@Override | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/GolangOrgVcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
package org.echocat.gradle.plugins.golang.vcs.isps;
public class GolangOrgVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
private static final Logger LOGGER = LoggerFactory.getLogger(GolangOrgVcsRepositoryProvider.class);
protected static final Pattern REF_PATTERN = compile("^refs/(?:heads|tags)/v(?<version>[0-9]{1,9}(?:\\.[0-9]{1,9}(?:\\.[0-9]{1,9})?)?)$");
public GolangOrgVcsRepositoryProvider() {
super("golang.org/", compile("^(?<root>golang\\.org/x/(?<repo>[A-Za-z0-9_.\\-]+))(?<subPath>/[A-Za-z0-9_.\\-]+)*$"));
}
@Nonnull
@Override | protected String rootFor(@Nonnull Matcher matcher, @Nonnull RawVcsReference rawReference) throws VcsException { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/DependenciesSettings.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
| import groovy.lang.Closure;
import groovy.lang.MissingMethodException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.util.CollectionUtils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import java.net.URI;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.echocat.gradle.plugins.golang.Constants.VENDOR_DIRECTORY_NAME;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
import static org.gradle.util.ConfigureUtil.configure; | }
public Path getDependencyCache() {
return _dependencyCache;
}
public void setDependencyCache(Path dependencyCache) {
_dependencyCache = dependencyCache;
}
public Collection<VcsRepositoryProvider> getVcsRepositoryProviders() {
return _vcsRepositoryProviders;
}
public void setVcsRepositoryProviders(Collection<VcsRepositoryProvider> vcsRepositoryProviders) {
_vcsRepositoryProviders = vcsRepositoryProviders;
}
@Nonnull
public VcsRepositoryProvider vcsRepositoryProvider(@Nonnull String prefix, @Nonnull String name, @Nonnull String dependencyPattern) {
return vcsRepositoryProvider(prefix, name, Pattern.compile(dependencyPattern));
}
@Nonnull
public VcsRepositoryProvider vcsRepositoryProvider(@Nonnull String prefix, @Nonnull String name, @Nonnull Pattern dependencyPattern) {
return vcsRepositoryProvider(git, prefix, name, dependencyPattern);
}
@Nonnull
public VcsRepositoryProvider vcsRepositoryProvider(@Nonnull String type, @Nonnull String prefix, @Nonnull String name, @Nonnull String dependencyPattern) { | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/DependenciesSettings.java
import groovy.lang.Closure;
import groovy.lang.MissingMethodException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.artifacts.Dependency;
import org.gradle.util.CollectionUtils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import java.net.URI;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.echocat.gradle.plugins.golang.Constants.VENDOR_DIRECTORY_NAME;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
import static org.gradle.util.ConfigureUtil.configure;
}
public Path getDependencyCache() {
return _dependencyCache;
}
public void setDependencyCache(Path dependencyCache) {
_dependencyCache = dependencyCache;
}
public Collection<VcsRepositoryProvider> getVcsRepositoryProviders() {
return _vcsRepositoryProviders;
}
public void setVcsRepositoryProviders(Collection<VcsRepositoryProvider> vcsRepositoryProviders) {
_vcsRepositoryProviders = vcsRepositoryProviders;
}
@Nonnull
public VcsRepositoryProvider vcsRepositoryProvider(@Nonnull String prefix, @Nonnull String name, @Nonnull String dependencyPattern) {
return vcsRepositoryProvider(prefix, name, Pattern.compile(dependencyPattern));
}
@Nonnull
public VcsRepositoryProvider vcsRepositoryProvider(@Nonnull String prefix, @Nonnull String name, @Nonnull Pattern dependencyPattern) {
return vcsRepositoryProvider(git, prefix, name, dependencyPattern);
}
@Nonnull
public VcsRepositoryProvider vcsRepositoryProvider(@Nonnull String type, @Nonnull String prefix, @Nonnull String name, @Nonnull String dependencyPattern) { | return vcsRepositoryProvider(VcsType.valueOf(type), prefix, name, Pattern.compile(dependencyPattern)); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/SuffixDetectingVcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import java.util.regex.Matcher;
import static java.util.regex.Pattern.compile; | package org.echocat.gradle.plugins.golang.vcs.isps;
public class SuffixDetectingVcsRepositoryProvider extends VcsRepositoryProviderSupport {
public SuffixDetectingVcsRepositoryProvider() {
super(compile("^(?<root>(?<repo>([a-z0-9.\\-]+\\.)+[a-z0-9.\\-]+(:[0-9]+)?(/~?[A-Za-z0-9_.\\-]+)+?)\\.(?<vcs>bzr|git|hg|svn))(?<path>/~?[A-Za-z0-9_.\\-]+)*$"));
}
@Override
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/SuffixDetectingVcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import java.util.regex.Matcher;
import static java.util.regex.Pattern.compile;
package org.echocat.gradle.plugins.golang.vcs.isps;
public class SuffixDetectingVcsRepositoryProvider extends VcsRepositoryProviderSupport {
public SuffixDetectingVcsRepositoryProvider() {
super(compile("^(?<root>(?<repo>([a-z0-9.\\-]+\\.)+[a-z0-9.\\-]+(:[0-9]+)?(/~?[A-Za-z0-9_.\\-]+)+?)\\.(?<vcs>bzr|git|hg|svn))(?<path>/~?[A-Za-z0-9_.\\-]+)*$"));
}
@Override
@Nonnull | protected VcsType detectVcsTypeOf(@Nonnull RawVcsReference rawReference) throws VcsException { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/SuffixDetectingVcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import java.util.regex.Matcher;
import static java.util.regex.Pattern.compile; | package org.echocat.gradle.plugins.golang.vcs.isps;
public class SuffixDetectingVcsRepositoryProvider extends VcsRepositoryProviderSupport {
public SuffixDetectingVcsRepositoryProvider() {
super(compile("^(?<root>(?<repo>([a-z0-9.\\-]+\\.)+[a-z0-9.\\-]+(:[0-9]+)?(/~?[A-Za-z0-9_.\\-]+)+?)\\.(?<vcs>bzr|git|hg|svn))(?<path>/~?[A-Za-z0-9_.\\-]+)*$"));
}
@Override
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/SuffixDetectingVcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import java.util.regex.Matcher;
import static java.util.regex.Pattern.compile;
package org.echocat.gradle.plugins.golang.vcs.isps;
public class SuffixDetectingVcsRepositoryProvider extends VcsRepositoryProviderSupport {
public SuffixDetectingVcsRepositoryProvider() {
super(compile("^(?<root>(?<repo>([a-z0-9.\\-]+\\.)+[a-z0-9.\\-]+(:[0-9]+)?(/~?[A-Za-z0-9_.\\-]+)+?)\\.(?<vcs>bzr|git|hg|svn))(?<path>/~?[A-Za-z0-9_.\\-]+)*$"));
}
@Override
@Nonnull | protected VcsType detectVcsTypeOf(@Nonnull RawVcsReference rawReference) throws VcsException { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/SuffixDetectingVcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import java.util.regex.Matcher;
import static java.util.regex.Pattern.compile; | package org.echocat.gradle.plugins.golang.vcs.isps;
public class SuffixDetectingVcsRepositoryProvider extends VcsRepositoryProviderSupport {
public SuffixDetectingVcsRepositoryProvider() {
super(compile("^(?<root>(?<repo>([a-z0-9.\\-]+\\.)+[a-z0-9.\\-]+(:[0-9]+)?(/~?[A-Za-z0-9_.\\-]+)+?)\\.(?<vcs>bzr|git|hg|svn))(?<path>/~?[A-Za-z0-9_.\\-]+)*$"));
}
@Override
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/SuffixDetectingVcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import java.util.regex.Matcher;
import static java.util.regex.Pattern.compile;
package org.echocat.gradle.plugins.golang.vcs.isps;
public class SuffixDetectingVcsRepositoryProvider extends VcsRepositoryProviderSupport {
public SuffixDetectingVcsRepositoryProvider() {
super(compile("^(?<root>(?<repo>([a-z0-9.\\-]+\\.)+[a-z0-9.\\-]+(:[0-9]+)?(/~?[A-Za-z0-9_.\\-]+)+?)\\.(?<vcs>bzr|git|hg|svn))(?<path>/~?[A-Za-z0-9_.\\-]+)*$"));
}
@Override
@Nonnull | protected VcsType detectVcsTypeOf(@Nonnull RawVcsReference rawReference) throws VcsException { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/SuffixDetectingVcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import java.util.regex.Matcher;
import static java.util.regex.Pattern.compile; | package org.echocat.gradle.plugins.golang.vcs.isps;
public class SuffixDetectingVcsRepositoryProvider extends VcsRepositoryProviderSupport {
public SuffixDetectingVcsRepositoryProvider() {
super(compile("^(?<root>(?<repo>([a-z0-9.\\-]+\\.)+[a-z0-9.\\-]+(:[0-9]+)?(/~?[A-Za-z0-9_.\\-]+)+?)\\.(?<vcs>bzr|git|hg|svn))(?<path>/~?[A-Za-z0-9_.\\-]+)*$"));
}
@Override
@Nonnull
protected VcsType detectVcsTypeOf(@Nonnull RawVcsReference rawReference) throws VcsException {
final Matcher matcher = nameMatcherFor(rawReference);
final VcsType type = VcsType.valueOf(matcher.group("vcs"));
return fixedVcsTypeFor(rawReference, type);
}
@Override
protected boolean couldHandle(@Nonnull RawVcsReference rawReference) {
return dependencyPattern().matcher(rawReference.getId()).matches();
}
@Override
@Nonnull
protected Matcher nameMatcherFor(@Nonnull RawVcsReference rawReference) throws VcsException {
final Matcher matcher = dependencyPattern().matcher(rawReference.getId());
if (!matcher.matches()) { | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/SuffixDetectingVcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import java.util.regex.Matcher;
import static java.util.regex.Pattern.compile;
package org.echocat.gradle.plugins.golang.vcs.isps;
public class SuffixDetectingVcsRepositoryProvider extends VcsRepositoryProviderSupport {
public SuffixDetectingVcsRepositoryProvider() {
super(compile("^(?<root>(?<repo>([a-z0-9.\\-]+\\.)+[a-z0-9.\\-]+(:[0-9]+)?(/~?[A-Za-z0-9_.\\-]+)+?)\\.(?<vcs>bzr|git|hg|svn))(?<path>/~?[A-Za-z0-9_.\\-]+)*$"));
}
@Override
@Nonnull
protected VcsType detectVcsTypeOf(@Nonnull RawVcsReference rawReference) throws VcsException {
final Matcher matcher = nameMatcherFor(rawReference);
final VcsType type = VcsType.valueOf(matcher.group("vcs"));
return fixedVcsTypeFor(rawReference, type);
}
@Override
protected boolean couldHandle(@Nonnull RawVcsReference rawReference) {
return dependencyPattern().matcher(rawReference.getId()).matches();
}
@Override
@Nonnull
protected Matcher nameMatcherFor(@Nonnull RawVcsReference rawReference) throws VcsException {
final Matcher matcher = dependencyPattern().matcher(rawReference.getId());
if (!matcher.matches()) { | throw new VcsValidationException("Name of dependency " + rawReference + " is invalid."); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Immutable
// public final class UpdatePolicy implements Comparable<UpdatePolicy> {
//
// private static final UpdatePolicy ALWAYS = new UpdatePolicy(Type.always, 0);
// private static final UpdatePolicy NEVER = new UpdatePolicy(Type.never, 0);
// private static final UpdatePolicy DAILY = new UpdatePolicy(Type.daily, 60L * 24L);
//
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
//
// @Nonnull
// public static UpdatePolicy interval(@Nonnegative long intervalInMinutes) {
// return new UpdatePolicy(Type.interval, intervalInMinutes);
// }
//
// @Nonnull
// public static UpdatePolicy always() {
// return ALWAYS;
// }
//
// @Nonnull
// public static UpdatePolicy never() {
// return NEVER;
// }
//
// @Nonnull
// public static UpdatePolicy daily() {
// return DAILY;
// }
//
// @Nonnull
// private final Type _type;
// @Nonnegative
// private final long _intervalInMinutes;
//
// @Nonnull
// public static UpdatePolicy valueOf(@Nullable String value) throws IllegalArgumentException {
// if (isEmpty(value)) {
// return defaultUpdatePolicy();
// }
// final String[] parts = StringUtils.split(value, ':');
// final Type type;
// try {
// type = Type.valueOf(parts[0]);
// } catch (final IllegalArgumentException ignored) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// if (type == Type.interval) {
// if (parts.length != 2) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// try {
// final long intervalInMinutes = Long.valueOf(parts[1]);
// if (intervalInMinutes < 0) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// return interval(intervalInMinutes);
// } catch (final NumberFormatException ignored) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// }
// if (parts.length != 1) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// if (type == Type.never) {
// return never();
// }
// if (type == Type.always) {
// return always();
// }
// if (type == Type.daily) {
// return always();
// }
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
//
// private UpdatePolicy(@Nonnull Type type, @Nonnegative long intervalInMinutes) {
// _type = type;
// _intervalInMinutes = intervalInMinutes;
// }
//
// public boolean updateRequired(@Nonnegative long lastUpdatedMillis) {
// final Type type = _type;
// if (type == Type.never) {
// return false;
// }
// if (type == Type.always) {
// return true;
// }
// final long updateRequiredAfter = lastUpdatedMillis + MINUTES.toMillis(_intervalInMinutes);
// return updateRequiredAfter < currentTimeMillis();
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append(_type);
// if (_type == Type.interval) {
// sb.append(':').append(_intervalInMinutes);
// }
// return sb.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) { return true; }
// if (o == null || getClass() != o.getClass()) { return false; }
// final UpdatePolicy that = (UpdatePolicy) o;
// return _intervalInMinutes == that._intervalInMinutes &&
// _type == that._type;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(_type, _intervalInMinutes);
// }
//
// @Override
// public int compareTo(@Nonnull UpdatePolicy that) {
// if (_intervalInMinutes != that._intervalInMinutes) {
// return Long.compare(_intervalInMinutes, that._intervalInMinutes);
// }
// if (_type != that._type) {
// return _type.compareTo(that._type);
// }
// return 0;
// }
//
// private enum Type {
// interval,
// always,
// never,
// daily
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
| import org.echocat.gradle.plugins.golang.model.UpdatePolicy;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.echocat.gradle.plugins.golang.model.UpdatePolicy.defaultUpdatePolicy; | package org.echocat.gradle.plugins.golang.vcs;
public class VcsReference extends BaseVcsReference {
@Nullable
private final String _subPath;
public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
return new VcsReference(type, name, plainUri, ref, subPath);
}
public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull String plain, @Nullable String ref, @Nullable String subPath) throws VcsValidationException { | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Immutable
// public final class UpdatePolicy implements Comparable<UpdatePolicy> {
//
// private static final UpdatePolicy ALWAYS = new UpdatePolicy(Type.always, 0);
// private static final UpdatePolicy NEVER = new UpdatePolicy(Type.never, 0);
// private static final UpdatePolicy DAILY = new UpdatePolicy(Type.daily, 60L * 24L);
//
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
//
// @Nonnull
// public static UpdatePolicy interval(@Nonnegative long intervalInMinutes) {
// return new UpdatePolicy(Type.interval, intervalInMinutes);
// }
//
// @Nonnull
// public static UpdatePolicy always() {
// return ALWAYS;
// }
//
// @Nonnull
// public static UpdatePolicy never() {
// return NEVER;
// }
//
// @Nonnull
// public static UpdatePolicy daily() {
// return DAILY;
// }
//
// @Nonnull
// private final Type _type;
// @Nonnegative
// private final long _intervalInMinutes;
//
// @Nonnull
// public static UpdatePolicy valueOf(@Nullable String value) throws IllegalArgumentException {
// if (isEmpty(value)) {
// return defaultUpdatePolicy();
// }
// final String[] parts = StringUtils.split(value, ':');
// final Type type;
// try {
// type = Type.valueOf(parts[0]);
// } catch (final IllegalArgumentException ignored) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// if (type == Type.interval) {
// if (parts.length != 2) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// try {
// final long intervalInMinutes = Long.valueOf(parts[1]);
// if (intervalInMinutes < 0) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// return interval(intervalInMinutes);
// } catch (final NumberFormatException ignored) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// }
// if (parts.length != 1) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// if (type == Type.never) {
// return never();
// }
// if (type == Type.always) {
// return always();
// }
// if (type == Type.daily) {
// return always();
// }
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
//
// private UpdatePolicy(@Nonnull Type type, @Nonnegative long intervalInMinutes) {
// _type = type;
// _intervalInMinutes = intervalInMinutes;
// }
//
// public boolean updateRequired(@Nonnegative long lastUpdatedMillis) {
// final Type type = _type;
// if (type == Type.never) {
// return false;
// }
// if (type == Type.always) {
// return true;
// }
// final long updateRequiredAfter = lastUpdatedMillis + MINUTES.toMillis(_intervalInMinutes);
// return updateRequiredAfter < currentTimeMillis();
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append(_type);
// if (_type == Type.interval) {
// sb.append(':').append(_intervalInMinutes);
// }
// return sb.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) { return true; }
// if (o == null || getClass() != o.getClass()) { return false; }
// final UpdatePolicy that = (UpdatePolicy) o;
// return _intervalInMinutes == that._intervalInMinutes &&
// _type == that._type;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(_type, _intervalInMinutes);
// }
//
// @Override
// public int compareTo(@Nonnull UpdatePolicy that) {
// if (_intervalInMinutes != that._intervalInMinutes) {
// return Long.compare(_intervalInMinutes, that._intervalInMinutes);
// }
// if (_type != that._type) {
// return _type.compareTo(that._type);
// }
// return 0;
// }
//
// private enum Type {
// interval,
// always,
// never,
// daily
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
import org.echocat.gradle.plugins.golang.model.UpdatePolicy;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.echocat.gradle.plugins.golang.model.UpdatePolicy.defaultUpdatePolicy;
package org.echocat.gradle.plugins.golang.vcs;
public class VcsReference extends BaseVcsReference {
@Nullable
private final String _subPath;
public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
return new VcsReference(type, name, plainUri, ref, subPath);
}
public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull String plain, @Nullable String ref, @Nullable String subPath) throws VcsValidationException { | super(type, id, URI.create(plain), ref, defaultUpdatePolicy()); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Immutable
// public final class UpdatePolicy implements Comparable<UpdatePolicy> {
//
// private static final UpdatePolicy ALWAYS = new UpdatePolicy(Type.always, 0);
// private static final UpdatePolicy NEVER = new UpdatePolicy(Type.never, 0);
// private static final UpdatePolicy DAILY = new UpdatePolicy(Type.daily, 60L * 24L);
//
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
//
// @Nonnull
// public static UpdatePolicy interval(@Nonnegative long intervalInMinutes) {
// return new UpdatePolicy(Type.interval, intervalInMinutes);
// }
//
// @Nonnull
// public static UpdatePolicy always() {
// return ALWAYS;
// }
//
// @Nonnull
// public static UpdatePolicy never() {
// return NEVER;
// }
//
// @Nonnull
// public static UpdatePolicy daily() {
// return DAILY;
// }
//
// @Nonnull
// private final Type _type;
// @Nonnegative
// private final long _intervalInMinutes;
//
// @Nonnull
// public static UpdatePolicy valueOf(@Nullable String value) throws IllegalArgumentException {
// if (isEmpty(value)) {
// return defaultUpdatePolicy();
// }
// final String[] parts = StringUtils.split(value, ':');
// final Type type;
// try {
// type = Type.valueOf(parts[0]);
// } catch (final IllegalArgumentException ignored) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// if (type == Type.interval) {
// if (parts.length != 2) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// try {
// final long intervalInMinutes = Long.valueOf(parts[1]);
// if (intervalInMinutes < 0) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// return interval(intervalInMinutes);
// } catch (final NumberFormatException ignored) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// }
// if (parts.length != 1) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// if (type == Type.never) {
// return never();
// }
// if (type == Type.always) {
// return always();
// }
// if (type == Type.daily) {
// return always();
// }
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
//
// private UpdatePolicy(@Nonnull Type type, @Nonnegative long intervalInMinutes) {
// _type = type;
// _intervalInMinutes = intervalInMinutes;
// }
//
// public boolean updateRequired(@Nonnegative long lastUpdatedMillis) {
// final Type type = _type;
// if (type == Type.never) {
// return false;
// }
// if (type == Type.always) {
// return true;
// }
// final long updateRequiredAfter = lastUpdatedMillis + MINUTES.toMillis(_intervalInMinutes);
// return updateRequiredAfter < currentTimeMillis();
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append(_type);
// if (_type == Type.interval) {
// sb.append(':').append(_intervalInMinutes);
// }
// return sb.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) { return true; }
// if (o == null || getClass() != o.getClass()) { return false; }
// final UpdatePolicy that = (UpdatePolicy) o;
// return _intervalInMinutes == that._intervalInMinutes &&
// _type == that._type;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(_type, _intervalInMinutes);
// }
//
// @Override
// public int compareTo(@Nonnull UpdatePolicy that) {
// if (_intervalInMinutes != that._intervalInMinutes) {
// return Long.compare(_intervalInMinutes, that._intervalInMinutes);
// }
// if (_type != that._type) {
// return _type.compareTo(that._type);
// }
// return 0;
// }
//
// private enum Type {
// interval,
// always,
// never,
// daily
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
| import org.echocat.gradle.plugins.golang.model.UpdatePolicy;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.echocat.gradle.plugins.golang.model.UpdatePolicy.defaultUpdatePolicy; | package org.echocat.gradle.plugins.golang.vcs;
public class VcsReference extends BaseVcsReference {
@Nullable
private final String _subPath;
public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
return new VcsReference(type, name, plainUri, ref, subPath);
}
public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull String plain, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
super(type, id, URI.create(plain), ref, defaultUpdatePolicy());
//noinspection ConstantConditions
if (type == null) {
throw new VcsValidationException("Empty type provided.");
}
if (isEmpty(plain)) {
throw new VcsValidationException("Empty uri provided.");
}
_subPath = subPath;
}
| // Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Immutable
// public final class UpdatePolicy implements Comparable<UpdatePolicy> {
//
// private static final UpdatePolicy ALWAYS = new UpdatePolicy(Type.always, 0);
// private static final UpdatePolicy NEVER = new UpdatePolicy(Type.never, 0);
// private static final UpdatePolicy DAILY = new UpdatePolicy(Type.daily, 60L * 24L);
//
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
//
// @Nonnull
// public static UpdatePolicy interval(@Nonnegative long intervalInMinutes) {
// return new UpdatePolicy(Type.interval, intervalInMinutes);
// }
//
// @Nonnull
// public static UpdatePolicy always() {
// return ALWAYS;
// }
//
// @Nonnull
// public static UpdatePolicy never() {
// return NEVER;
// }
//
// @Nonnull
// public static UpdatePolicy daily() {
// return DAILY;
// }
//
// @Nonnull
// private final Type _type;
// @Nonnegative
// private final long _intervalInMinutes;
//
// @Nonnull
// public static UpdatePolicy valueOf(@Nullable String value) throws IllegalArgumentException {
// if (isEmpty(value)) {
// return defaultUpdatePolicy();
// }
// final String[] parts = StringUtils.split(value, ':');
// final Type type;
// try {
// type = Type.valueOf(parts[0]);
// } catch (final IllegalArgumentException ignored) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// if (type == Type.interval) {
// if (parts.length != 2) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// try {
// final long intervalInMinutes = Long.valueOf(parts[1]);
// if (intervalInMinutes < 0) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// return interval(intervalInMinutes);
// } catch (final NumberFormatException ignored) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// }
// if (parts.length != 1) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// if (type == Type.never) {
// return never();
// }
// if (type == Type.always) {
// return always();
// }
// if (type == Type.daily) {
// return always();
// }
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
//
// private UpdatePolicy(@Nonnull Type type, @Nonnegative long intervalInMinutes) {
// _type = type;
// _intervalInMinutes = intervalInMinutes;
// }
//
// public boolean updateRequired(@Nonnegative long lastUpdatedMillis) {
// final Type type = _type;
// if (type == Type.never) {
// return false;
// }
// if (type == Type.always) {
// return true;
// }
// final long updateRequiredAfter = lastUpdatedMillis + MINUTES.toMillis(_intervalInMinutes);
// return updateRequiredAfter < currentTimeMillis();
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append(_type);
// if (_type == Type.interval) {
// sb.append(':').append(_intervalInMinutes);
// }
// return sb.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) { return true; }
// if (o == null || getClass() != o.getClass()) { return false; }
// final UpdatePolicy that = (UpdatePolicy) o;
// return _intervalInMinutes == that._intervalInMinutes &&
// _type == that._type;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(_type, _intervalInMinutes);
// }
//
// @Override
// public int compareTo(@Nonnull UpdatePolicy that) {
// if (_intervalInMinutes != that._intervalInMinutes) {
// return Long.compare(_intervalInMinutes, that._intervalInMinutes);
// }
// if (_type != that._type) {
// return _type.compareTo(that._type);
// }
// return 0;
// }
//
// private enum Type {
// interval,
// always,
// never,
// daily
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
import org.echocat.gradle.plugins.golang.model.UpdatePolicy;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.echocat.gradle.plugins.golang.model.UpdatePolicy.defaultUpdatePolicy;
package org.echocat.gradle.plugins.golang.vcs;
public class VcsReference extends BaseVcsReference {
@Nullable
private final String _subPath;
public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
return new VcsReference(type, name, plainUri, ref, subPath);
}
public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull String plain, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
super(type, id, URI.create(plain), ref, defaultUpdatePolicy());
//noinspection ConstantConditions
if (type == null) {
throw new VcsValidationException("Empty type provided.");
}
if (isEmpty(plain)) {
throw new VcsValidationException("Empty uri provided.");
}
_subPath = subPath;
}
| public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull URI uri, @Nullable String ref, @Nonnull UpdatePolicy updatePolicy, @Nullable String subPath) { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/VcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/DefaultVcsRepositoryProvider.java
// public class DefaultVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
//
// @Nonnull
// private final VcsType _type;
// @Nonnull
// private final String _name;
//
// public DefaultVcsRepositoryProvider(@Nonnull VcsType type, @Nonnull String prefix, @Nonnull String name, @Nonnull Pattern dependencyPattern) {
// super(prefix, dependencyPattern);
// _type = type;
// _name = name;
// }
//
// @Nonnull
// @Override
// protected VcsType detectVcsTypeOf(@Nonnull RawVcsReference rawReference) throws VcsException {
// return fixedVcsTypeFor(rawReference, _type);
// }
//
// @Nonnull
// @Override
// protected String getName() {
// return _name;
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.isps.DefaultVcsRepositoryProvider;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git; | package org.echocat.gradle.plugins.golang.model;
@Immutable
public class VcsRepositoryProvider {
@Nonnull
private static final List<VcsRepositoryProvider> DEFAULTS = unmodifiableList(asList(
new VcsRepositoryProvider(git, "github.com/", "GitHub", compile("^(?<root>github\\.com/[A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+)(?<subPath>/[A-Za-z0-9_.\\-]+)*$")),
new VcsRepositoryProvider(git, "gopkg.in/", "gopkg.in", compile("^(?<root>gopkg\\.in(?<repo>(?:/[A-Za-z0-9_.\\-]+){1,2})\\.v(?<version>[0-9]{1,9}))(?<subPath>/[A-Za-z0-9_.\\-]+)*$")),
new VcsRepositoryProvider(git, "git.apache.org/", "Git at Apache", compile("^(?<root>git.apache.org/[a-z0-9_.\\-]+\\.git)(?<subPath>/[A-Za-z0-9_.\\-]+)*$")),
new VcsRepositoryProvider(git, "git.openstack.org/", "OpenStack Git Repository", compile("^(?<root>git\\.openstack\\.org/[A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+)(\\.git)?(?<subPath>/[A-Za-z0-9_.\\-]+)*$")),
new VcsRepositoryProvider(git, "hub.jazz.net/git/", "IBM Bluemix DevOps Services", compile("^(?<root>hub\\.jazz\\.net/git/[a-z0-9]+/[A-Za-z0-9_.\\-]+)(?<subPath>/[A-Za-z0-9_.\\-]+)*$"))
));
private static final List<org.echocat.gradle.plugins.golang.vcs.VcsRepositoryProvider> DEFAULT_CONCRETES = toConcrete(DEFAULTS);
@Nonnull
public static List<VcsRepositoryProvider> defaults() {
return DEFAULTS;
}
@Nonnull
public static List<org.echocat.gradle.plugins.golang.vcs.VcsRepositoryProvider> defaultConcretes() {
return DEFAULT_CONCRETES;
}
@Nonnull
private final String _prefix;
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/DefaultVcsRepositoryProvider.java
// public class DefaultVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
//
// @Nonnull
// private final VcsType _type;
// @Nonnull
// private final String _name;
//
// public DefaultVcsRepositoryProvider(@Nonnull VcsType type, @Nonnull String prefix, @Nonnull String name, @Nonnull Pattern dependencyPattern) {
// super(prefix, dependencyPattern);
// _type = type;
// _name = name;
// }
//
// @Nonnull
// @Override
// protected VcsType detectVcsTypeOf(@Nonnull RawVcsReference rawReference) throws VcsException {
// return fixedVcsTypeFor(rawReference, _type);
// }
//
// @Nonnull
// @Override
// protected String getName() {
// return _name;
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/VcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.isps.DefaultVcsRepositoryProvider;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
package org.echocat.gradle.plugins.golang.model;
@Immutable
public class VcsRepositoryProvider {
@Nonnull
private static final List<VcsRepositoryProvider> DEFAULTS = unmodifiableList(asList(
new VcsRepositoryProvider(git, "github.com/", "GitHub", compile("^(?<root>github\\.com/[A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+)(?<subPath>/[A-Za-z0-9_.\\-]+)*$")),
new VcsRepositoryProvider(git, "gopkg.in/", "gopkg.in", compile("^(?<root>gopkg\\.in(?<repo>(?:/[A-Za-z0-9_.\\-]+){1,2})\\.v(?<version>[0-9]{1,9}))(?<subPath>/[A-Za-z0-9_.\\-]+)*$")),
new VcsRepositoryProvider(git, "git.apache.org/", "Git at Apache", compile("^(?<root>git.apache.org/[a-z0-9_.\\-]+\\.git)(?<subPath>/[A-Za-z0-9_.\\-]+)*$")),
new VcsRepositoryProvider(git, "git.openstack.org/", "OpenStack Git Repository", compile("^(?<root>git\\.openstack\\.org/[A-Za-z0-9_.\\-]+/[A-Za-z0-9_.\\-]+)(\\.git)?(?<subPath>/[A-Za-z0-9_.\\-]+)*$")),
new VcsRepositoryProvider(git, "hub.jazz.net/git/", "IBM Bluemix DevOps Services", compile("^(?<root>hub\\.jazz\\.net/git/[a-z0-9]+/[A-Za-z0-9_.\\-]+)(?<subPath>/[A-Za-z0-9_.\\-]+)*$"))
));
private static final List<org.echocat.gradle.plugins.golang.vcs.VcsRepositoryProvider> DEFAULT_CONCRETES = toConcrete(DEFAULTS);
@Nonnull
public static List<VcsRepositoryProvider> defaults() {
return DEFAULTS;
}
@Nonnull
public static List<org.echocat.gradle.plugins.golang.vcs.VcsRepositoryProvider> defaultConcretes() {
return DEFAULT_CONCRETES;
}
@Nonnull
private final String _prefix;
@Nonnull | private final VcsType _type; |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/VcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/DefaultVcsRepositoryProvider.java
// public class DefaultVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
//
// @Nonnull
// private final VcsType _type;
// @Nonnull
// private final String _name;
//
// public DefaultVcsRepositoryProvider(@Nonnull VcsType type, @Nonnull String prefix, @Nonnull String name, @Nonnull Pattern dependencyPattern) {
// super(prefix, dependencyPattern);
// _type = type;
// _name = name;
// }
//
// @Nonnull
// @Override
// protected VcsType detectVcsTypeOf(@Nonnull RawVcsReference rawReference) throws VcsException {
// return fixedVcsTypeFor(rawReference, _type);
// }
//
// @Nonnull
// @Override
// protected String getName() {
// return _name;
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.isps.DefaultVcsRepositoryProvider;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git; | _dependencyPattern = dependencyPattern;
}
@Nonnull
public String getPrefix() {
return _prefix;
}
@Nonnull
public VcsType getType() {
return _type;
}
@Nonnull
public String getName() {
return _name;
}
@Nonnull
public Pattern getDependencyPattern() {
return _dependencyPattern;
}
@Override
public String toString() {
return getName() + "{prefix: " + getPrefix() + ", type: " + getType() + ", dependencyPattern: " + getDependencyPattern() + "}";
}
@Nonnull
public org.echocat.gradle.plugins.golang.vcs.VcsRepositoryProvider toConcrete() { | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/DefaultVcsRepositoryProvider.java
// public class DefaultVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
//
// @Nonnull
// private final VcsType _type;
// @Nonnull
// private final String _name;
//
// public DefaultVcsRepositoryProvider(@Nonnull VcsType type, @Nonnull String prefix, @Nonnull String name, @Nonnull Pattern dependencyPattern) {
// super(prefix, dependencyPattern);
// _type = type;
// _name = name;
// }
//
// @Nonnull
// @Override
// protected VcsType detectVcsTypeOf(@Nonnull RawVcsReference rawReference) throws VcsException {
// return fixedVcsTypeFor(rawReference, _type);
// }
//
// @Nonnull
// @Override
// protected String getName() {
// return _name;
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/VcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.isps.DefaultVcsRepositoryProvider;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
_dependencyPattern = dependencyPattern;
}
@Nonnull
public String getPrefix() {
return _prefix;
}
@Nonnull
public VcsType getType() {
return _type;
}
@Nonnull
public String getName() {
return _name;
}
@Nonnull
public Pattern getDependencyPattern() {
return _dependencyPattern;
}
@Override
public String toString() {
return getName() + "{prefix: " + getPrefix() + ", type: " + getType() + ", dependencyPattern: " + getDependencyPattern() + "}";
}
@Nonnull
public org.echocat.gradle.plugins.golang.vcs.VcsRepositoryProvider toConcrete() { | return new DefaultVcsRepositoryProvider(getType(), getPrefix(), getName(), getDependencyPattern()); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/git/GitVcsRepository.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void deleteQuietly(@Nullable Path path) {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// try {
// doDelete(path);
// } catch (final IOException ignored) {}
// return;
// }
// try {
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
// try {
// doDelete(file);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
// try {
// doDelete(dir);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
// });
// } catch (final IOException ignored) {}
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/git/GitVcsUri.java
// @Nonnull
// public static GitVcsUri gitVcsUriFor(@Nonnull VcsReference reference) {
// return gitVcsUriFor(reference.getUri());
// }
| import com.sun.nio.sctp.IllegalReceiveException;
import org.echocat.gradle.plugins.golang.vcs.*;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.transport.HttpTransport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.nio.file.Path;
import java.util.regex.Pattern;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.deleteQuietly;
import static org.echocat.gradle.plugins.golang.vcs.git.GitVcsUri.gitVcsUriFor; | package org.echocat.gradle.plugins.golang.vcs.git;
public class GitVcsRepository extends VcsRepositorySupport {
static {
HttpTransport.setConnectionFactory(new HttpConnectionFactoryImpl());
}
protected static final Pattern SPLIT_PATH_PATTERN = Pattern.compile("^(?<root>/[A-Za-z0-9_.\\-/]+?\\.git)(?<subPath>/.*|)$");
private static final Logger LOGGER = LoggerFactory.getLogger(VcsRepositorySupport.class);
public GitVcsRepository(@Nonnull VcsReference ref) {
super(ref);
}
@Override
public boolean isWorking() throws VcsException {
try {
return resolveRemoteRef() != null;
} catch (final IllegalReceiveException ignored) {
return false;
} catch (final GitAPIException e) {
throw new VcsException(e);
}
}
@Override
@Nonnull
protected VcsFullReference downloadToInternal(@Nonnull Path targetDirectory, @Nullable ProgressMonitor progressMonitor) throws VcsException {
Ref ref = null; | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void deleteQuietly(@Nullable Path path) {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// try {
// doDelete(path);
// } catch (final IOException ignored) {}
// return;
// }
// try {
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
// try {
// doDelete(file);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
// try {
// doDelete(dir);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
// });
// } catch (final IOException ignored) {}
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/git/GitVcsUri.java
// @Nonnull
// public static GitVcsUri gitVcsUriFor(@Nonnull VcsReference reference) {
// return gitVcsUriFor(reference.getUri());
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/git/GitVcsRepository.java
import com.sun.nio.sctp.IllegalReceiveException;
import org.echocat.gradle.plugins.golang.vcs.*;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.transport.HttpTransport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.nio.file.Path;
import java.util.regex.Pattern;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.deleteQuietly;
import static org.echocat.gradle.plugins.golang.vcs.git.GitVcsUri.gitVcsUriFor;
package org.echocat.gradle.plugins.golang.vcs.git;
public class GitVcsRepository extends VcsRepositorySupport {
static {
HttpTransport.setConnectionFactory(new HttpConnectionFactoryImpl());
}
protected static final Pattern SPLIT_PATH_PATTERN = Pattern.compile("^(?<root>/[A-Za-z0-9_.\\-/]+?\\.git)(?<subPath>/.*|)$");
private static final Logger LOGGER = LoggerFactory.getLogger(VcsRepositorySupport.class);
public GitVcsRepository(@Nonnull VcsReference ref) {
super(ref);
}
@Override
public boolean isWorking() throws VcsException {
try {
return resolveRemoteRef() != null;
} catch (final IllegalReceiveException ignored) {
return false;
} catch (final GitAPIException e) {
throw new VcsException(e);
}
}
@Override
@Nonnull
protected VcsFullReference downloadToInternal(@Nonnull Path targetDirectory, @Nullable ProgressMonitor progressMonitor) throws VcsException {
Ref ref = null; | final GitVcsUri uri = gitVcsUriFor(getReference()); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/IspBasedVcsRepositoryProviderSupport.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.apache.commons.lang3.StringUtils.isEmpty; | package org.echocat.gradle.plugins.golang.vcs.isps;
public abstract class IspBasedVcsRepositoryProviderSupport extends VcsRepositoryProviderSupport {
@Nullable
private final String _prefix;
public IspBasedVcsRepositoryProviderSupport(@Nullable String prefix, @Nonnull Pattern dependencyPattern) {
super(dependencyPattern);
_prefix = prefix;
}
@Override | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/IspBasedVcsRepositoryProviderSupport.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.apache.commons.lang3.StringUtils.isEmpty;
package org.echocat.gradle.plugins.golang.vcs.isps;
public abstract class IspBasedVcsRepositoryProviderSupport extends VcsRepositoryProviderSupport {
@Nullable
private final String _prefix;
public IspBasedVcsRepositoryProviderSupport(@Nullable String prefix, @Nonnull Pattern dependencyPattern) {
super(dependencyPattern);
_prefix = prefix;
}
@Override | protected boolean couldHandle(@Nonnull RawVcsReference rawReference) { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/IspBasedVcsRepositoryProviderSupport.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.apache.commons.lang3.StringUtils.isEmpty; | package org.echocat.gradle.plugins.golang.vcs.isps;
public abstract class IspBasedVcsRepositoryProviderSupport extends VcsRepositoryProviderSupport {
@Nullable
private final String _prefix;
public IspBasedVcsRepositoryProviderSupport(@Nullable String prefix, @Nonnull Pattern dependencyPattern) {
super(dependencyPattern);
_prefix = prefix;
}
@Override
protected boolean couldHandle(@Nonnull RawVcsReference rawReference) {
final String name = rawReference.getId();
return name.startsWith(prefix());
}
@Override
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/IspBasedVcsRepositoryProviderSupport.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.apache.commons.lang3.StringUtils.isEmpty;
package org.echocat.gradle.plugins.golang.vcs.isps;
public abstract class IspBasedVcsRepositoryProviderSupport extends VcsRepositoryProviderSupport {
@Nullable
private final String _prefix;
public IspBasedVcsRepositoryProviderSupport(@Nullable String prefix, @Nonnull Pattern dependencyPattern) {
super(dependencyPattern);
_prefix = prefix;
}
@Override
protected boolean couldHandle(@Nonnull RawVcsReference rawReference) {
final String name = rawReference.getId();
return name.startsWith(prefix());
}
@Override
@Nonnull | protected Matcher nameMatcherFor(@Nonnull RawVcsReference rawReference) throws VcsException { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/IspBasedVcsRepositoryProviderSupport.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.apache.commons.lang3.StringUtils.isEmpty; | package org.echocat.gradle.plugins.golang.vcs.isps;
public abstract class IspBasedVcsRepositoryProviderSupport extends VcsRepositoryProviderSupport {
@Nullable
private final String _prefix;
public IspBasedVcsRepositoryProviderSupport(@Nullable String prefix, @Nonnull Pattern dependencyPattern) {
super(dependencyPattern);
_prefix = prefix;
}
@Override
protected boolean couldHandle(@Nonnull RawVcsReference rawReference) {
final String name = rawReference.getId();
return name.startsWith(prefix());
}
@Override
@Nonnull
protected Matcher nameMatcherFor(@Nonnull RawVcsReference rawReference) throws VcsException {
final Matcher matcher = dependencyPattern().matcher(rawReference.getId());
if (!matcher.matches()) { | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/IspBasedVcsRepositoryProviderSupport.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.apache.commons.lang3.StringUtils.isEmpty;
package org.echocat.gradle.plugins.golang.vcs.isps;
public abstract class IspBasedVcsRepositoryProviderSupport extends VcsRepositoryProviderSupport {
@Nullable
private final String _prefix;
public IspBasedVcsRepositoryProviderSupport(@Nullable String prefix, @Nonnull Pattern dependencyPattern) {
super(dependencyPattern);
_prefix = prefix;
}
@Override
protected boolean couldHandle(@Nonnull RawVcsReference rawReference) {
final String name = rawReference.getId();
return name.startsWith(prefix());
}
@Override
@Nonnull
protected Matcher nameMatcherFor(@Nonnull RawVcsReference rawReference) throws VcsException {
final Matcher matcher = dependencyPattern().matcher(rawReference.getId());
if (!matcher.matches()) { | throw new VcsValidationException("Name of dependency " + rawReference + " is invalid for " + getName() + "."); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/GolangSettings.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// @Nullable
// public static Path toPath(@Nullable String plain) {
// return plain != null ? Paths.get(plain) : null;
// }
| import org.gradle.api.Project;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.toPath; | package org.echocat.gradle.plugins.golang.model;
public class GolangSettings {
@Nonnull
private final Project _project;
private List<Platform> _platforms;
private String _packageName;
private Platform _hostPlatform;
private Path _cacheRoot;
@Inject
public GolangSettings(boolean initialize, @Nonnull Project project) {
_project = project;
if (initialize) { | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// @Nullable
// public static Path toPath(@Nullable String plain) {
// return plain != null ? Paths.get(plain) : null;
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangSettings.java
import org.gradle.api.Project;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.toPath;
package org.echocat.gradle.plugins.golang.model;
public class GolangSettings {
@Nonnull
private final Project _project;
private List<Platform> _platforms;
private String _packageName;
private Platform _hostPlatform;
private Path _cacheRoot;
@Inject
public GolangSettings(boolean initialize, @Nonnull Project project) {
_project = project;
if (initialize) { | setHostPlatform(currentPlatform()); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/GolangSettings.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// @Nullable
// public static Path toPath(@Nullable String plain) {
// return plain != null ? Paths.get(plain) : null;
// }
| import org.gradle.api.Project;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.toPath; |
public String getPackageName() {
return _packageName;
}
public void setPackageName(String packageName) {
_packageName = packageName;
}
public Platform getHostPlatform() {
return _hostPlatform;
}
public void setHostPlatform(Platform hostPlatform) {
_hostPlatform = hostPlatform;
}
public void setHostPlatform(String hostPlatform) {
setHostPlatform(hostPlatform != null ? Platform.resolveForGo(hostPlatform) : null);
}
public Path getCacheRoot() {
return _cacheRoot;
}
public void setCacheRoot(Path cacheRoot) {
_cacheRoot = cacheRoot;
}
public void setCacheRoot(String cacheRoot) { | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// @Nullable
// public static Path toPath(@Nullable String plain) {
// return plain != null ? Paths.get(plain) : null;
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangSettings.java
import org.gradle.api.Project;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.toPath;
public String getPackageName() {
return _packageName;
}
public void setPackageName(String packageName) {
_packageName = packageName;
}
public Platform getHostPlatform() {
return _hostPlatform;
}
public void setHostPlatform(Platform hostPlatform) {
_hostPlatform = hostPlatform;
}
public void setHostPlatform(String hostPlatform) {
setHostPlatform(hostPlatform != null ? Platform.resolveForGo(hostPlatform) : null);
}
public Path getCacheRoot() {
return _cacheRoot;
}
public void setCacheRoot(Path cacheRoot) {
_cacheRoot = cacheRoot;
}
public void setCacheRoot(String cacheRoot) { | setCacheRoot(toPath(cacheRoot)); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/utils/ArchiveUtils.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void createDirectoriesIfRequired(@Nonnull Path path) throws IOException {
// if (!exists(path)) {
// createDirectories(path);
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void deleteQuietly(@Nullable Path path) {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// try {
// doDelete(path);
// } catch (final IOException ignored) {}
// return;
// }
// try {
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
// try {
// doDelete(file);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
// try {
// doDelete(dir);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
// });
// } catch (final IOException ignored) {}
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void ensureParentOf(@Nonnull Path path) throws IOException {
// createDirectoriesIfRequired(path.getParent());
// }
| import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Request.Builder;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import static java.nio.file.Files.*;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.copy;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.createDirectoriesIfRequired;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.deleteQuietly;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.ensureParentOf; | package org.echocat.gradle.plugins.golang.utils;
public class ArchiveUtils {
private static final Pattern REMOVE_LEADING_GO_PATH_PATTERN = Pattern.compile("^(|\\./)go/");
public static void download(URI uri, Path to) throws IOException {
if (exists(to)) { | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void createDirectoriesIfRequired(@Nonnull Path path) throws IOException {
// if (!exists(path)) {
// createDirectories(path);
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void deleteQuietly(@Nullable Path path) {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// try {
// doDelete(path);
// } catch (final IOException ignored) {}
// return;
// }
// try {
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
// try {
// doDelete(file);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
// try {
// doDelete(dir);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
// });
// } catch (final IOException ignored) {}
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void ensureParentOf(@Nonnull Path path) throws IOException {
// createDirectoriesIfRequired(path.getParent());
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/ArchiveUtils.java
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Request.Builder;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import static java.nio.file.Files.*;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.copy;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.createDirectoriesIfRequired;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.deleteQuietly;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.ensureParentOf;
package org.echocat.gradle.plugins.golang.utils;
public class ArchiveUtils {
private static final Pattern REMOVE_LEADING_GO_PATH_PATTERN = Pattern.compile("^(|\\./)go/");
public static void download(URI uri, Path to) throws IOException {
if (exists(to)) { | deleteQuietly(to); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/utils/ArchiveUtils.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void createDirectoriesIfRequired(@Nonnull Path path) throws IOException {
// if (!exists(path)) {
// createDirectories(path);
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void deleteQuietly(@Nullable Path path) {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// try {
// doDelete(path);
// } catch (final IOException ignored) {}
// return;
// }
// try {
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
// try {
// doDelete(file);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
// try {
// doDelete(dir);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
// });
// } catch (final IOException ignored) {}
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void ensureParentOf(@Nonnull Path path) throws IOException {
// createDirectoriesIfRequired(path.getParent());
// }
| import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Request.Builder;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import static java.nio.file.Files.*;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.copy;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.createDirectoriesIfRequired;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.deleteQuietly;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.ensureParentOf; | package org.echocat.gradle.plugins.golang.utils;
public class ArchiveUtils {
private static final Pattern REMOVE_LEADING_GO_PATH_PATTERN = Pattern.compile("^(|\\./)go/");
public static void download(URI uri, Path to) throws IOException {
if (exists(to)) {
deleteQuietly(to);
} | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void createDirectoriesIfRequired(@Nonnull Path path) throws IOException {
// if (!exists(path)) {
// createDirectories(path);
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void deleteQuietly(@Nullable Path path) {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// try {
// doDelete(path);
// } catch (final IOException ignored) {}
// return;
// }
// try {
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
// try {
// doDelete(file);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
// try {
// doDelete(dir);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
// });
// } catch (final IOException ignored) {}
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void ensureParentOf(@Nonnull Path path) throws IOException {
// createDirectoriesIfRequired(path.getParent());
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/ArchiveUtils.java
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Request.Builder;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import static java.nio.file.Files.*;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.copy;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.createDirectoriesIfRequired;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.deleteQuietly;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.ensureParentOf;
package org.echocat.gradle.plugins.golang.utils;
public class ArchiveUtils {
private static final Pattern REMOVE_LEADING_GO_PATH_PATTERN = Pattern.compile("^(|\\./)go/");
public static void download(URI uri, Path to) throws IOException {
if (exists(to)) {
deleteQuietly(to);
} | createDirectoriesIfRequired(to); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/utils/ArchiveUtils.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void createDirectoriesIfRequired(@Nonnull Path path) throws IOException {
// if (!exists(path)) {
// createDirectories(path);
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void deleteQuietly(@Nullable Path path) {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// try {
// doDelete(path);
// } catch (final IOException ignored) {}
// return;
// }
// try {
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
// try {
// doDelete(file);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
// try {
// doDelete(dir);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
// });
// } catch (final IOException ignored) {}
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void ensureParentOf(@Nonnull Path path) throws IOException {
// createDirectoriesIfRequired(path.getParent());
// }
| import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Request.Builder;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import static java.nio.file.Files.*;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.copy;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.createDirectoriesIfRequired;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.deleteQuietly;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.ensureParentOf; |
final Path tempFile = createTempFile("golang-maven-plugin", "." + getExtension(uri.toString()));
try {
try (final InputStream is = client.newCall(request).execute().body().byteStream()) {
try (final OutputStream os = newOutputStream(tempFile)) {
copy(is, os);
}
}
if (uri.toString().endsWith(".tar.gz")) {
unTarGz(tempFile, to);
} else if (uri.toString().endsWith(".zip")) {
unZip(tempFile, to);
} else {
throw new IllegalStateException("Does not support download archive of type " + uri + ".");
}
} finally {
deleteQuietly(tempFile);
}
}
public static void unTarGz(Path file, Path target) throws IOException {
try (final InputStream is = newInputStream(file)) {
final InputStream gzip = new GZIPInputStream(is);
final TarArchiveInputStream archive = new TarArchiveInputStream(gzip);
TarArchiveEntry entry = archive.getNextTarEntry();
while (entry != null) {
final Path entryFile = target.resolve(REMOVE_LEADING_GO_PATH_PATTERN.matcher(entry.getName()).replaceFirst("")).toAbsolutePath();
if (entry.isDirectory()) {
createDirectoriesIfRequired(entryFile);
} else { | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void createDirectoriesIfRequired(@Nonnull Path path) throws IOException {
// if (!exists(path)) {
// createDirectories(path);
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void deleteQuietly(@Nullable Path path) {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// try {
// doDelete(path);
// } catch (final IOException ignored) {}
// return;
// }
// try {
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
// try {
// doDelete(file);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
// try {
// doDelete(dir);
// } catch (final IOException ignored) {}
// return CONTINUE;
// }
// });
// } catch (final IOException ignored) {}
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void ensureParentOf(@Nonnull Path path) throws IOException {
// createDirectoriesIfRequired(path.getParent());
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/ArchiveUtils.java
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Request.Builder;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipFile;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import static java.nio.file.Files.*;
import static org.apache.commons.io.FilenameUtils.getExtension;
import static org.apache.commons.io.IOUtils.copy;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.createDirectoriesIfRequired;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.deleteQuietly;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.ensureParentOf;
final Path tempFile = createTempFile("golang-maven-plugin", "." + getExtension(uri.toString()));
try {
try (final InputStream is = client.newCall(request).execute().body().byteStream()) {
try (final OutputStream os = newOutputStream(tempFile)) {
copy(is, os);
}
}
if (uri.toString().endsWith(".tar.gz")) {
unTarGz(tempFile, to);
} else if (uri.toString().endsWith(".zip")) {
unZip(tempFile, to);
} else {
throw new IllegalStateException("Does not support download archive of type " + uri + ".");
}
} finally {
deleteQuietly(tempFile);
}
}
public static void unTarGz(Path file, Path target) throws IOException {
try (final InputStream is = newInputStream(file)) {
final InputStream gzip = new GZIPInputStream(is);
final TarArchiveInputStream archive = new TarArchiveInputStream(gzip);
TarArchiveEntry entry = archive.getNextTarEntry();
while (entry != null) {
final Path entryFile = target.resolve(REMOVE_LEADING_GO_PATH_PATTERN.matcher(entry.getName()).replaceFirst("")).toAbsolutePath();
if (entry.isDirectory()) {
createDirectoriesIfRequired(entryFile);
} else { | ensureParentOf(entryFile); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/tasks/BaseGetTools.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// public enum GetResult {
// downloaded,
// alreadyExists
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
// public enum Type {
// explicit,
// implicit,
// source,
// system
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// @Nonnull
// public static GetTask by(@Nonnull String configuration) {
// return new GetTask(configuration);
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void delete(@Nullable Path path) throws IOException {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// doDelete(path);
// return;
// }
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// doDelete(file);
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// doDelete(dir);
// return CONTINUE;
// }
// });
// }
| import org.echocat.gradle.plugins.golang.DependencyHandler.GetResult;
import org.echocat.gradle.plugins.golang.model.*;
import org.echocat.gradle.plugins.golang.model.GolangDependency.Type;
import org.gradle.internal.logging.progress.ProgressLogger;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.Boolean.TRUE;
import static java.nio.file.Files.exists;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetResult.downloaded;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetTask.by;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.delete;
import static org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE; | package org.echocat.gradle.plugins.golang.tasks;
public class BaseGetTools extends GolangTaskSupport {
public BaseGetTools() {
setGroup("tools");
setDescription("Download and build required tools for base artifacts.");
dependsOn(
"validate",
"prepareToolchain"
);
}
@Override
public void run() throws Exception {
final ProgressLogger progress = startProgress("Get tools");
| // Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// public enum GetResult {
// downloaded,
// alreadyExists
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
// public enum Type {
// explicit,
// implicit,
// source,
// system
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// @Nonnull
// public static GetTask by(@Nonnull String configuration) {
// return new GetTask(configuration);
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void delete(@Nullable Path path) throws IOException {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// doDelete(path);
// return;
// }
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// doDelete(file);
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// doDelete(dir);
// return CONTINUE;
// }
// });
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/tasks/BaseGetTools.java
import org.echocat.gradle.plugins.golang.DependencyHandler.GetResult;
import org.echocat.gradle.plugins.golang.model.*;
import org.echocat.gradle.plugins.golang.model.GolangDependency.Type;
import org.gradle.internal.logging.progress.ProgressLogger;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.Boolean.TRUE;
import static java.nio.file.Files.exists;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetResult.downloaded;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetTask.by;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.delete;
import static org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE;
package org.echocat.gradle.plugins.golang.tasks;
public class BaseGetTools extends GolangTaskSupport {
public BaseGetTools() {
setGroup("tools");
setDescription("Download and build required tools for base artifacts.");
dependsOn(
"validate",
"prepareToolchain"
);
}
@Override
public void run() throws Exception {
final ProgressLogger progress = startProgress("Get tools");
| final Map<GolangDependency, GetResult> dependencies = getDependencyHandler().get(by("tool")); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/tasks/BaseGetTools.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// public enum GetResult {
// downloaded,
// alreadyExists
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
// public enum Type {
// explicit,
// implicit,
// source,
// system
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// @Nonnull
// public static GetTask by(@Nonnull String configuration) {
// return new GetTask(configuration);
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void delete(@Nullable Path path) throws IOException {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// doDelete(path);
// return;
// }
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// doDelete(file);
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// doDelete(dir);
// return CONTINUE;
// }
// });
// }
| import org.echocat.gradle.plugins.golang.DependencyHandler.GetResult;
import org.echocat.gradle.plugins.golang.model.*;
import org.echocat.gradle.plugins.golang.model.GolangDependency.Type;
import org.gradle.internal.logging.progress.ProgressLogger;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.Boolean.TRUE;
import static java.nio.file.Files.exists;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetResult.downloaded;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetTask.by;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.delete;
import static org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE; | package org.echocat.gradle.plugins.golang.tasks;
public class BaseGetTools extends GolangTaskSupport {
public BaseGetTools() {
setGroup("tools");
setDescription("Download and build required tools for base artifacts.");
dependsOn(
"validate",
"prepareToolchain"
);
}
@Override
public void run() throws Exception {
final ProgressLogger progress = startProgress("Get tools");
| // Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// public enum GetResult {
// downloaded,
// alreadyExists
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
// public enum Type {
// explicit,
// implicit,
// source,
// system
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// @Nonnull
// public static GetTask by(@Nonnull String configuration) {
// return new GetTask(configuration);
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void delete(@Nullable Path path) throws IOException {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// doDelete(path);
// return;
// }
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// doDelete(file);
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// doDelete(dir);
// return CONTINUE;
// }
// });
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/tasks/BaseGetTools.java
import org.echocat.gradle.plugins.golang.DependencyHandler.GetResult;
import org.echocat.gradle.plugins.golang.model.*;
import org.echocat.gradle.plugins.golang.model.GolangDependency.Type;
import org.gradle.internal.logging.progress.ProgressLogger;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.Boolean.TRUE;
import static java.nio.file.Files.exists;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetResult.downloaded;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetTask.by;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.delete;
import static org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE;
package org.echocat.gradle.plugins.golang.tasks;
public class BaseGetTools extends GolangTaskSupport {
public BaseGetTools() {
setGroup("tools");
setDescription("Download and build required tools for base artifacts.");
dependsOn(
"validate",
"prepareToolchain"
);
}
@Override
public void run() throws Exception {
final ProgressLogger progress = startProgress("Get tools");
| final Map<GolangDependency, GetResult> dependencies = getDependencyHandler().get(by("tool")); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/tasks/BaseGetTools.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// public enum GetResult {
// downloaded,
// alreadyExists
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
// public enum Type {
// explicit,
// implicit,
// source,
// system
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// @Nonnull
// public static GetTask by(@Nonnull String configuration) {
// return new GetTask(configuration);
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void delete(@Nullable Path path) throws IOException {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// doDelete(path);
// return;
// }
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// doDelete(file);
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// doDelete(dir);
// return CONTINUE;
// }
// });
// }
| import org.echocat.gradle.plugins.golang.DependencyHandler.GetResult;
import org.echocat.gradle.plugins.golang.model.*;
import org.echocat.gradle.plugins.golang.model.GolangDependency.Type;
import org.gradle.internal.logging.progress.ProgressLogger;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.Boolean.TRUE;
import static java.nio.file.Files.exists;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetResult.downloaded;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetTask.by;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.delete;
import static org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE; | package org.echocat.gradle.plugins.golang.tasks;
public class BaseGetTools extends GolangTaskSupport {
public BaseGetTools() {
setGroup("tools");
setDescription("Download and build required tools for base artifacts.");
dependsOn(
"validate",
"prepareToolchain"
);
}
@Override
public void run() throws Exception {
final ProgressLogger progress = startProgress("Get tools");
final Map<GolangDependency, GetResult> dependencies = getDependencyHandler().get(by("tool"));
boolean atLeastOneBuild = false;
for (final Entry<GolangDependency, GetResult> entry : dependencies.entrySet()) {
final GolangDependency dependency = entry.getKey(); | // Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// public enum GetResult {
// downloaded,
// alreadyExists
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
// public enum Type {
// explicit,
// implicit,
// source,
// system
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// @Nonnull
// public static GetTask by(@Nonnull String configuration) {
// return new GetTask(configuration);
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void delete(@Nullable Path path) throws IOException {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// doDelete(path);
// return;
// }
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// doDelete(file);
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// doDelete(dir);
// return CONTINUE;
// }
// });
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/tasks/BaseGetTools.java
import org.echocat.gradle.plugins.golang.DependencyHandler.GetResult;
import org.echocat.gradle.plugins.golang.model.*;
import org.echocat.gradle.plugins.golang.model.GolangDependency.Type;
import org.gradle.internal.logging.progress.ProgressLogger;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.Boolean.TRUE;
import static java.nio.file.Files.exists;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetResult.downloaded;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetTask.by;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.delete;
import static org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE;
package org.echocat.gradle.plugins.golang.tasks;
public class BaseGetTools extends GolangTaskSupport {
public BaseGetTools() {
setGroup("tools");
setDescription("Download and build required tools for base artifacts.");
dependsOn(
"validate",
"prepareToolchain"
);
}
@Override
public void run() throws Exception {
final ProgressLogger progress = startProgress("Get tools");
final Map<GolangDependency, GetResult> dependencies = getDependencyHandler().get(by("tool"));
boolean atLeastOneBuild = false;
for (final Entry<GolangDependency, GetResult> entry : dependencies.entrySet()) {
final GolangDependency dependency = entry.getKey(); | if (dependency.getType() == Type.explicit) { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/tasks/BaseGetTools.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// public enum GetResult {
// downloaded,
// alreadyExists
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
// public enum Type {
// explicit,
// implicit,
// source,
// system
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// @Nonnull
// public static GetTask by(@Nonnull String configuration) {
// return new GetTask(configuration);
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void delete(@Nullable Path path) throws IOException {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// doDelete(path);
// return;
// }
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// doDelete(file);
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// doDelete(dir);
// return CONTINUE;
// }
// });
// }
| import org.echocat.gradle.plugins.golang.DependencyHandler.GetResult;
import org.echocat.gradle.plugins.golang.model.*;
import org.echocat.gradle.plugins.golang.model.GolangDependency.Type;
import org.gradle.internal.logging.progress.ProgressLogger;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.Boolean.TRUE;
import static java.nio.file.Files.exists;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetResult.downloaded;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetTask.by;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.delete;
import static org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE; | "validate",
"prepareToolchain"
);
}
@Override
public void run() throws Exception {
final ProgressLogger progress = startProgress("Get tools");
final Map<GolangDependency, GetResult> dependencies = getDependencyHandler().get(by("tool"));
boolean atLeastOneBuild = false;
for (final Entry<GolangDependency, GetResult> entry : dependencies.entrySet()) {
final GolangDependency dependency = entry.getKey();
if (dependency.getType() == Type.explicit) {
if (buildIfRequired(dependency, entry.getValue(), progress)) {
atLeastOneBuild = true;
}
}
}
if (!atLeastOneBuild) {
getState().setOutcome(UP_TO_DATE);
}
progress.completed();
}
protected boolean buildIfRequired(@Nonnull GolangDependency dependency, @Nonnull GetResult getResult, @Nonnull ProgressLogger progress) throws Exception {
final GolangSettings settings = getGolang();
final BuildSettings build = getBuild();
final ToolchainSettings toolchain = getToolchain(); | // Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// public enum GetResult {
// downloaded,
// alreadyExists
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
// public enum Type {
// explicit,
// implicit,
// source,
// system
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// @Nonnull
// public static GetTask by(@Nonnull String configuration) {
// return new GetTask(configuration);
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void delete(@Nullable Path path) throws IOException {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// doDelete(path);
// return;
// }
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// doDelete(file);
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// doDelete(dir);
// return CONTINUE;
// }
// });
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/tasks/BaseGetTools.java
import org.echocat.gradle.plugins.golang.DependencyHandler.GetResult;
import org.echocat.gradle.plugins.golang.model.*;
import org.echocat.gradle.plugins.golang.model.GolangDependency.Type;
import org.gradle.internal.logging.progress.ProgressLogger;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.Boolean.TRUE;
import static java.nio.file.Files.exists;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetResult.downloaded;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetTask.by;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.delete;
import static org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE;
"validate",
"prepareToolchain"
);
}
@Override
public void run() throws Exception {
final ProgressLogger progress = startProgress("Get tools");
final Map<GolangDependency, GetResult> dependencies = getDependencyHandler().get(by("tool"));
boolean atLeastOneBuild = false;
for (final Entry<GolangDependency, GetResult> entry : dependencies.entrySet()) {
final GolangDependency dependency = entry.getKey();
if (dependency.getType() == Type.explicit) {
if (buildIfRequired(dependency, entry.getValue(), progress)) {
atLeastOneBuild = true;
}
}
}
if (!atLeastOneBuild) {
getState().setOutcome(UP_TO_DATE);
}
progress.completed();
}
protected boolean buildIfRequired(@Nonnull GolangDependency dependency, @Nonnull GetResult getResult, @Nonnull ProgressLogger progress) throws Exception {
final GolangSettings settings = getGolang();
final BuildSettings build = getBuild();
final ToolchainSettings toolchain = getToolchain(); | final Platform platform = currentPlatform(); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/tasks/BaseGetTools.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// public enum GetResult {
// downloaded,
// alreadyExists
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
// public enum Type {
// explicit,
// implicit,
// source,
// system
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// @Nonnull
// public static GetTask by(@Nonnull String configuration) {
// return new GetTask(configuration);
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void delete(@Nullable Path path) throws IOException {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// doDelete(path);
// return;
// }
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// doDelete(file);
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// doDelete(dir);
// return CONTINUE;
// }
// });
// }
| import org.echocat.gradle.plugins.golang.DependencyHandler.GetResult;
import org.echocat.gradle.plugins.golang.model.*;
import org.echocat.gradle.plugins.golang.model.GolangDependency.Type;
import org.gradle.internal.logging.progress.ProgressLogger;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.Boolean.TRUE;
import static java.nio.file.Files.exists;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetResult.downloaded;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetTask.by;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.delete;
import static org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE; | public void run() throws Exception {
final ProgressLogger progress = startProgress("Get tools");
final Map<GolangDependency, GetResult> dependencies = getDependencyHandler().get(by("tool"));
boolean atLeastOneBuild = false;
for (final Entry<GolangDependency, GetResult> entry : dependencies.entrySet()) {
final GolangDependency dependency = entry.getKey();
if (dependency.getType() == Type.explicit) {
if (buildIfRequired(dependency, entry.getValue(), progress)) {
atLeastOneBuild = true;
}
}
}
if (!atLeastOneBuild) {
getState().setOutcome(UP_TO_DATE);
}
progress.completed();
}
protected boolean buildIfRequired(@Nonnull GolangDependency dependency, @Nonnull GetResult getResult, @Nonnull ProgressLogger progress) throws Exception {
final GolangSettings settings = getGolang();
final BuildSettings build = getBuild();
final ToolchainSettings toolchain = getToolchain();
final Platform platform = currentPlatform();
final Path targetBinaryFilename = targetBinaryFilename(dependency);
if (getResult == downloaded || !exists(targetBinaryFilename)) {
getLogger().info("Get tool {}...", dependency.getGroup());
progress.progress("Get tool " + dependency.getGroup() + "..."); | // Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// public enum GetResult {
// downloaded,
// alreadyExists
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
// public enum Type {
// explicit,
// implicit,
// source,
// system
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// @Nonnull
// public static GetTask by(@Nonnull String configuration) {
// return new GetTask(configuration);
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void delete(@Nullable Path path) throws IOException {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// doDelete(path);
// return;
// }
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// doDelete(file);
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// doDelete(dir);
// return CONTINUE;
// }
// });
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/tasks/BaseGetTools.java
import org.echocat.gradle.plugins.golang.DependencyHandler.GetResult;
import org.echocat.gradle.plugins.golang.model.*;
import org.echocat.gradle.plugins.golang.model.GolangDependency.Type;
import org.gradle.internal.logging.progress.ProgressLogger;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.Boolean.TRUE;
import static java.nio.file.Files.exists;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetResult.downloaded;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetTask.by;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.delete;
import static org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE;
public void run() throws Exception {
final ProgressLogger progress = startProgress("Get tools");
final Map<GolangDependency, GetResult> dependencies = getDependencyHandler().get(by("tool"));
boolean atLeastOneBuild = false;
for (final Entry<GolangDependency, GetResult> entry : dependencies.entrySet()) {
final GolangDependency dependency = entry.getKey();
if (dependency.getType() == Type.explicit) {
if (buildIfRequired(dependency, entry.getValue(), progress)) {
atLeastOneBuild = true;
}
}
}
if (!atLeastOneBuild) {
getState().setOutcome(UP_TO_DATE);
}
progress.completed();
}
protected boolean buildIfRequired(@Nonnull GolangDependency dependency, @Nonnull GetResult getResult, @Nonnull ProgressLogger progress) throws Exception {
final GolangSettings settings = getGolang();
final BuildSettings build = getBuild();
final ToolchainSettings toolchain = getToolchain();
final Platform platform = currentPlatform();
final Path targetBinaryFilename = targetBinaryFilename(dependency);
if (getResult == downloaded || !exists(targetBinaryFilename)) {
getLogger().info("Get tool {}...", dependency.getGroup());
progress.progress("Get tool " + dependency.getGroup() + "..."); | delete(targetBinaryFilename.getParent()); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/tasks/BaseGetTools.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// public enum GetResult {
// downloaded,
// alreadyExists
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
// public enum Type {
// explicit,
// implicit,
// source,
// system
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// @Nonnull
// public static GetTask by(@Nonnull String configuration) {
// return new GetTask(configuration);
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void delete(@Nullable Path path) throws IOException {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// doDelete(path);
// return;
// }
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// doDelete(file);
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// doDelete(dir);
// return CONTINUE;
// }
// });
// }
| import org.echocat.gradle.plugins.golang.DependencyHandler.GetResult;
import org.echocat.gradle.plugins.golang.model.*;
import org.echocat.gradle.plugins.golang.model.GolangDependency.Type;
import org.gradle.internal.logging.progress.ProgressLogger;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.Boolean.TRUE;
import static java.nio.file.Files.exists;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetResult.downloaded;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetTask.by;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.delete;
import static org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE; |
final Map<GolangDependency, GetResult> dependencies = getDependencyHandler().get(by("tool"));
boolean atLeastOneBuild = false;
for (final Entry<GolangDependency, GetResult> entry : dependencies.entrySet()) {
final GolangDependency dependency = entry.getKey();
if (dependency.getType() == Type.explicit) {
if (buildIfRequired(dependency, entry.getValue(), progress)) {
atLeastOneBuild = true;
}
}
}
if (!atLeastOneBuild) {
getState().setOutcome(UP_TO_DATE);
}
progress.completed();
}
protected boolean buildIfRequired(@Nonnull GolangDependency dependency, @Nonnull GetResult getResult, @Nonnull ProgressLogger progress) throws Exception {
final GolangSettings settings = getGolang();
final BuildSettings build = getBuild();
final ToolchainSettings toolchain = getToolchain();
final Platform platform = currentPlatform();
final Path targetBinaryFilename = targetBinaryFilename(dependency);
if (getResult == downloaded || !exists(targetBinaryFilename)) {
getLogger().info("Get tool {}...", dependency.getGroup());
progress.progress("Get tool " + dependency.getGroup() + "...");
delete(targetBinaryFilename.getParent());
| // Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// public enum GetResult {
// downloaded,
// alreadyExists
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
// public enum Type {
// explicit,
// implicit,
// source,
// system
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/DependencyHandler.java
// @Nonnull
// public static GetTask by(@Nonnull String configuration) {
// return new GetTask(configuration);
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Platform.java
// @Nonnull
// public static Platform currentPlatform() {
// return CURRENT;
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// public static void delete(@Nullable Path path) throws IOException {
// if (path == null || !exists(path)) {
// return;
// }
// if (isRegularFile(path)) {
// doDelete(path);
// return;
// }
// walkFileTree(path, new SimpleFileVisitor<Path>() {
// @Override
// public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
// doDelete(file);
// return CONTINUE;
// }
//
// @Override
// public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
// doDelete(dir);
// return CONTINUE;
// }
// });
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/tasks/BaseGetTools.java
import org.echocat.gradle.plugins.golang.DependencyHandler.GetResult;
import org.echocat.gradle.plugins.golang.model.*;
import org.echocat.gradle.plugins.golang.model.GolangDependency.Type;
import org.gradle.internal.logging.progress.ProgressLogger;
import javax.annotation.Nonnull;
import java.nio.file.Path;
import java.util.Map;
import java.util.Map.Entry;
import static java.lang.Boolean.TRUE;
import static java.nio.file.Files.exists;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetResult.downloaded;
import static org.echocat.gradle.plugins.golang.DependencyHandler.GetTask.by;
import static org.echocat.gradle.plugins.golang.model.Platform.currentPlatform;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.delete;
import static org.gradle.api.internal.tasks.TaskExecutionOutcome.UP_TO_DATE;
final Map<GolangDependency, GetResult> dependencies = getDependencyHandler().get(by("tool"));
boolean atLeastOneBuild = false;
for (final Entry<GolangDependency, GetResult> entry : dependencies.entrySet()) {
final GolangDependency dependency = entry.getKey();
if (dependency.getType() == Type.explicit) {
if (buildIfRequired(dependency, entry.getValue(), progress)) {
atLeastOneBuild = true;
}
}
}
if (!atLeastOneBuild) {
getState().setOutcome(UP_TO_DATE);
}
progress.completed();
}
protected boolean buildIfRequired(@Nonnull GolangDependency dependency, @Nonnull GetResult getResult, @Nonnull ProgressLogger progress) throws Exception {
final GolangSettings settings = getGolang();
final BuildSettings build = getBuild();
final ToolchainSettings toolchain = getToolchain();
final Platform platform = currentPlatform();
final Path targetBinaryFilename = targetBinaryFilename(dependency);
if (getResult == downloaded || !exists(targetBinaryFilename)) {
getLogger().info("Get tool {}...", dependency.getGroup());
progress.progress("Get tool " + dependency.getGroup() + "...");
delete(targetBinaryFilename.getParent());
| executor(toolchain.getGoBinary()) |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/utils/SettingsEnabled.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/Settings.java
// public class Settings {
//
// @Nonnull
// private final Project _project;
// @Nonnull
// private final GolangSettings _golang;
// @Nonnull
// private final BuildSettings _build;
// @Nonnull
// private final ToolchainSettings _toolchain;
// @Nonnull
// private final DependenciesSettings _dependencies;
// @Nonnull
// private final TestingSettings _testing;
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container) {
// _project = project;
// _golang = container.getByType(GolangSettings.class);
// if (!(_golang instanceof ExtensionAware)) {
// throw new IllegalStateException("golang instance (" + _golang + ") of provided extension container (" + container + ") is not an instance of " + ExtensionAware.class.getName() + ".");
// }
// final ExtensionContainer globalExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = globalExtensions.getByType(BuildSettings.class);
// _toolchain = globalExtensions.getByType(ToolchainSettings.class);
// _dependencies = globalExtensions.getByType(DependenciesSettings.class);
// _testing = globalExtensions.getByType(TestingSettings.class);
// }
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container, boolean init) {
// _project = project;
// _golang = container.create("golang", GolangSettings.class, init, project);
// final ExtensionContainer taskExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = taskExtensions.create("build", BuildSettings.class, init, project);
// _toolchain = taskExtensions.create("toolchain", ToolchainSettings.class, init, project);
// _dependencies = taskExtensions.create("dependencies", DependenciesSettings.class, init, project);
// _testing = taskExtensions.create("testing", TestingSettings.class, init, project);
// }
//
// public Settings(@Nonnull Project project, @Nonnull GolangSettings golang, @Nonnull BuildSettings build, @Nonnull ToolchainSettings toolchain, @Nonnull DependenciesSettings dependencies, @Nonnull TestingSettings testing) {
// _project = project;
// _golang = golang;
// _build = build;
// _toolchain = toolchain;
// _dependencies = dependencies;
// _testing = testing;
// }
//
// @Nonnull
// public GolangSettings getGolang() {
// return _golang;
// }
//
// @Nonnull
// public BuildSettings getBuild() {
// return _build;
// }
//
// @Nonnull
// public ToolchainSettings getToolchain() {
// return _toolchain;
// }
//
// @Nonnull
// public DependenciesSettings getDependencies() {
// return _dependencies;
// }
//
// @Nonnull
// public TestingSettings getTesting() {
// return _testing;
// }
//
// @Nonnull
// public Project getProject() {
// return _project;
// }
//
// @Nonnull
// public Settings merge(@Nonnull Settings... with) {
// final GolangSettings golang = new GolangSettings(false, _project);
// final BuildSettings build = new BuildSettings(false, _project);
// final ToolchainSettings toolchain = new ToolchainSettings(false, _project);
// final DependenciesSettings dependencies = new DependenciesSettings(false, _project);
// final TestingSettings testing = new TestingSettings(false, _project);
//
// copyNonNulls(GolangSettings.class, _golang, golang);
// copyNonNulls(BuildSettings.class, _build, build);
// copyNonNulls(ToolchainSettings.class, _toolchain, toolchain);
// copyNonNulls(DependenciesSettings.class, _dependencies, dependencies);
// copyNonNulls(TestingSettings.class, _testing, testing);
//
// for (final Settings source : with) {
// copyNonNulls(GolangSettings.class, source.getGolang(), golang);
// copyNonNulls(BuildSettings.class, source.getBuild(), build);
// copyNonNulls(ToolchainSettings.class, source.getToolchain(), toolchain);
// copyNonNulls(DependenciesSettings.class, source.getDependencies(), dependencies);
// copyNonNulls(TestingSettings.class, source.getTesting(), testing);
// }
//
// return new Settings(_project, golang, build, toolchain, dependencies, testing);
// }
// }
| import org.echocat.gradle.plugins.golang.model.Settings;
import javax.annotation.Nonnull; | package org.echocat.gradle.plugins.golang.utils;
public interface SettingsEnabled {
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/Settings.java
// public class Settings {
//
// @Nonnull
// private final Project _project;
// @Nonnull
// private final GolangSettings _golang;
// @Nonnull
// private final BuildSettings _build;
// @Nonnull
// private final ToolchainSettings _toolchain;
// @Nonnull
// private final DependenciesSettings _dependencies;
// @Nonnull
// private final TestingSettings _testing;
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container) {
// _project = project;
// _golang = container.getByType(GolangSettings.class);
// if (!(_golang instanceof ExtensionAware)) {
// throw new IllegalStateException("golang instance (" + _golang + ") of provided extension container (" + container + ") is not an instance of " + ExtensionAware.class.getName() + ".");
// }
// final ExtensionContainer globalExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = globalExtensions.getByType(BuildSettings.class);
// _toolchain = globalExtensions.getByType(ToolchainSettings.class);
// _dependencies = globalExtensions.getByType(DependenciesSettings.class);
// _testing = globalExtensions.getByType(TestingSettings.class);
// }
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container, boolean init) {
// _project = project;
// _golang = container.create("golang", GolangSettings.class, init, project);
// final ExtensionContainer taskExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = taskExtensions.create("build", BuildSettings.class, init, project);
// _toolchain = taskExtensions.create("toolchain", ToolchainSettings.class, init, project);
// _dependencies = taskExtensions.create("dependencies", DependenciesSettings.class, init, project);
// _testing = taskExtensions.create("testing", TestingSettings.class, init, project);
// }
//
// public Settings(@Nonnull Project project, @Nonnull GolangSettings golang, @Nonnull BuildSettings build, @Nonnull ToolchainSettings toolchain, @Nonnull DependenciesSettings dependencies, @Nonnull TestingSettings testing) {
// _project = project;
// _golang = golang;
// _build = build;
// _toolchain = toolchain;
// _dependencies = dependencies;
// _testing = testing;
// }
//
// @Nonnull
// public GolangSettings getGolang() {
// return _golang;
// }
//
// @Nonnull
// public BuildSettings getBuild() {
// return _build;
// }
//
// @Nonnull
// public ToolchainSettings getToolchain() {
// return _toolchain;
// }
//
// @Nonnull
// public DependenciesSettings getDependencies() {
// return _dependencies;
// }
//
// @Nonnull
// public TestingSettings getTesting() {
// return _testing;
// }
//
// @Nonnull
// public Project getProject() {
// return _project;
// }
//
// @Nonnull
// public Settings merge(@Nonnull Settings... with) {
// final GolangSettings golang = new GolangSettings(false, _project);
// final BuildSettings build = new BuildSettings(false, _project);
// final ToolchainSettings toolchain = new ToolchainSettings(false, _project);
// final DependenciesSettings dependencies = new DependenciesSettings(false, _project);
// final TestingSettings testing = new TestingSettings(false, _project);
//
// copyNonNulls(GolangSettings.class, _golang, golang);
// copyNonNulls(BuildSettings.class, _build, build);
// copyNonNulls(ToolchainSettings.class, _toolchain, toolchain);
// copyNonNulls(DependenciesSettings.class, _dependencies, dependencies);
// copyNonNulls(TestingSettings.class, _testing, testing);
//
// for (final Settings source : with) {
// copyNonNulls(GolangSettings.class, source.getGolang(), golang);
// copyNonNulls(BuildSettings.class, source.getBuild(), build);
// copyNonNulls(ToolchainSettings.class, source.getToolchain(), toolchain);
// copyNonNulls(DependenciesSettings.class, source.getDependencies(), dependencies);
// copyNonNulls(TestingSettings.class, source.getTesting(), testing);
// }
//
// return new Settings(_project, golang, build, toolchain, dependencies, testing);
// }
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/SettingsEnabled.java
import org.echocat.gradle.plugins.golang.model.Settings;
import javax.annotation.Nonnull;
package org.echocat.gradle.plugins.golang.utils;
public interface SettingsEnabled {
@Nonnull | public Settings getSettings(); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/TestingSettings.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// @Nullable
// public static Path toPath(@Nullable String plain) {
// return plain != null ? Paths.get(plain) : null;
// }
| import org.gradle.api.Project;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.nio.file.Path;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.toPath; | package org.echocat.gradle.plugins.golang.model;
public class TestingSettings {
@SuppressWarnings({"FieldCanBeLocal", "unused"})
@Nonnull
private final Project _project;
private Boolean _skip;
private String[] _packages;
private String[] _includes;
private String[] _excludes;
private String[] _testArguments;
private String[] _arguments;
/**
* Write a coverage profile to the file after all tests have passed.
* Sets -cover.
*/
private Path _coverProfile;
/**
* Write a coverage profile as HTML to the file after all tests have passed.
* Sets -cover.
*/
private Path _coverProfileHtml;
/**
* If set to an non <code>null</code> value the test output will
* will be stored in the specified file location.
*
* Default is: ${buildDir}/testing/test.log
*/
private Path _log;
/**
* If set to an non <code>null</code> value the test output will
* transformed into a junit report and will be written to this file location.
*
* Default is: ${buildDir}/testing/junit_report.xml
*/
private Path _junitReport;
@Inject
public TestingSettings(boolean initialize, @Nonnull Project project) {
_project = project;
if (initialize) {
_includes = new String[]{
"**/*_test.go"
};
_excludes = new String[]{
".git/**", ".svn/**", "build.gradle", "build/**", ".gradle/**", "gradle/**", "vendor/**"
}; | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// @Nullable
// public static Path toPath(@Nullable String plain) {
// return plain != null ? Paths.get(plain) : null;
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/TestingSettings.java
import org.gradle.api.Project;
import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.nio.file.Path;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.toPath;
package org.echocat.gradle.plugins.golang.model;
public class TestingSettings {
@SuppressWarnings({"FieldCanBeLocal", "unused"})
@Nonnull
private final Project _project;
private Boolean _skip;
private String[] _packages;
private String[] _includes;
private String[] _excludes;
private String[] _testArguments;
private String[] _arguments;
/**
* Write a coverage profile to the file after all tests have passed.
* Sets -cover.
*/
private Path _coverProfile;
/**
* Write a coverage profile as HTML to the file after all tests have passed.
* Sets -cover.
*/
private Path _coverProfileHtml;
/**
* If set to an non <code>null</code> value the test output will
* will be stored in the specified file location.
*
* Default is: ${buildDir}/testing/test.log
*/
private Path _log;
/**
* If set to an non <code>null</code> value the test output will
* transformed into a junit report and will be written to this file location.
*
* Default is: ${buildDir}/testing/junit_report.xml
*/
private Path _junitReport;
@Inject
public TestingSettings(boolean initialize, @Nonnull Project project) {
_project = project;
if (initialize) {
_includes = new String[]{
"**/*_test.go"
};
_excludes = new String[]{
".git/**", ".svn/**", "build.gradle", "build/**", ".gradle/**", "gradle/**", "vendor/**"
}; | _log = project.getBuildDir().toPath().resolve("testing").resolve("test.log"); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/ArtifactInfoCache.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/Version.java
// public class Version {
//
// private static final Properties PROPERTIES = load();
//
// public static final String VERSION = PROPERTIES.getProperty("version", "unknown");
// public static final String GROUP = PROPERTIES.getProperty("group", Version.class.getPackage().getName());
// public static final String NAME = PROPERTIES.getProperty("name", Version.class.getPackage().getName());
// public static final String DESCIPTION = PROPERTIES.getProperty("description", "");
//
// private static Properties load() {
// final Properties result = new Properties();
// final InputStream is = Version.class.getClassLoader().getResourceAsStream("org/echocat/gradle/plugins/golang/version.properties");
// if (is != null) {
// try (final Reader reader = new InputStreamReader(is, "UTF-8")) {
// result.load(reader);
// } catch (final IOException e) {
// throw new RuntimeException("Could not read version.properties.", e);
// } finally {
// closeQuietly(is);
// }
// }
// return result;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsFullReference.java
// public class VcsFullReference {
//
// @Nonnull
// private final VcsReference _reference;
// @Nonnull
// private final String _full;
//
// public VcsFullReference(@Nonnull VcsReference reference, @Nonnull String full) {
// _reference = reference;
// _full = full;
// }
//
// @Nonnull
// public VcsReference getReference() {
// return _reference;
// }
//
// @Nonnull
// public String getFull() {
// return _full;
// }
//
// }
| import com.google.gson.annotations.SerializedName;
import org.echocat.gradle.plugins.golang.Version;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsFullReference;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;
import java.util.TreeMap;
import static java.lang.System.currentTimeMillis; | package org.echocat.gradle.plugins.golang.model;
public class ArtifactInfoCache {
@SerializedName("revision")
private int _revision = 1;
@SerializedName("creator") | // Path: src/main/java/org/echocat/gradle/plugins/golang/Version.java
// public class Version {
//
// private static final Properties PROPERTIES = load();
//
// public static final String VERSION = PROPERTIES.getProperty("version", "unknown");
// public static final String GROUP = PROPERTIES.getProperty("group", Version.class.getPackage().getName());
// public static final String NAME = PROPERTIES.getProperty("name", Version.class.getPackage().getName());
// public static final String DESCIPTION = PROPERTIES.getProperty("description", "");
//
// private static Properties load() {
// final Properties result = new Properties();
// final InputStream is = Version.class.getClassLoader().getResourceAsStream("org/echocat/gradle/plugins/golang/version.properties");
// if (is != null) {
// try (final Reader reader = new InputStreamReader(is, "UTF-8")) {
// result.load(reader);
// } catch (final IOException e) {
// throw new RuntimeException("Could not read version.properties.", e);
// } finally {
// closeQuietly(is);
// }
// }
// return result;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsFullReference.java
// public class VcsFullReference {
//
// @Nonnull
// private final VcsReference _reference;
// @Nonnull
// private final String _full;
//
// public VcsFullReference(@Nonnull VcsReference reference, @Nonnull String full) {
// _reference = reference;
// _full = full;
// }
//
// @Nonnull
// public VcsReference getReference() {
// return _reference;
// }
//
// @Nonnull
// public String getFull() {
// return _full;
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/ArtifactInfoCache.java
import com.google.gson.annotations.SerializedName;
import org.echocat.gradle.plugins.golang.Version;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsFullReference;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;
import java.util.TreeMap;
import static java.lang.System.currentTimeMillis;
package org.echocat.gradle.plugins.golang.model;
public class ArtifactInfoCache {
@SerializedName("revision")
private int _revision = 1;
@SerializedName("creator") | private String _creator = Version.NAME + " " + Version.VERSION; |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/ArtifactInfoCache.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/Version.java
// public class Version {
//
// private static final Properties PROPERTIES = load();
//
// public static final String VERSION = PROPERTIES.getProperty("version", "unknown");
// public static final String GROUP = PROPERTIES.getProperty("group", Version.class.getPackage().getName());
// public static final String NAME = PROPERTIES.getProperty("name", Version.class.getPackage().getName());
// public static final String DESCIPTION = PROPERTIES.getProperty("description", "");
//
// private static Properties load() {
// final Properties result = new Properties();
// final InputStream is = Version.class.getClassLoader().getResourceAsStream("org/echocat/gradle/plugins/golang/version.properties");
// if (is != null) {
// try (final Reader reader = new InputStreamReader(is, "UTF-8")) {
// result.load(reader);
// } catch (final IOException e) {
// throw new RuntimeException("Could not read version.properties.", e);
// } finally {
// closeQuietly(is);
// }
// }
// return result;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsFullReference.java
// public class VcsFullReference {
//
// @Nonnull
// private final VcsReference _reference;
// @Nonnull
// private final String _full;
//
// public VcsFullReference(@Nonnull VcsReference reference, @Nonnull String full) {
// _reference = reference;
// _full = full;
// }
//
// @Nonnull
// public VcsReference getReference() {
// return _reference;
// }
//
// @Nonnull
// public String getFull() {
// return _full;
// }
//
// }
| import com.google.gson.annotations.SerializedName;
import org.echocat.gradle.plugins.golang.Version;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsFullReference;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;
import java.util.TreeMap;
import static java.lang.System.currentTimeMillis; |
public Map<String, Entry> getEntries() {
return _entries;
}
@Nullable
public Entry findEntryBy(@Nonnull String id) {
final Map<String, Entry> entries = _entries;
if (entries == null) {
return null;
}
return entries.get(id);
}
public void saveEntry(@Nonnull String id, @Nonnull Entry entry) {
if (_entries == null) {
_entries = new TreeMap<>();
}
_entries.put(id, entry);
}
public void saveEntry(@Nonnull String id, @Nullable String ref, @Nonnull String detailedRef, @Nonnegative long lastUpdatedMillis, boolean managed) {
final Entry entry = new Entry();
entry.setRef(ref);
entry.setDetailedRef(detailedRef);
entry.setLastUpdatedMillis(lastUpdatedMillis);
entry.setManaged(managed);
saveEntry(id, entry);
}
| // Path: src/main/java/org/echocat/gradle/plugins/golang/Version.java
// public class Version {
//
// private static final Properties PROPERTIES = load();
//
// public static final String VERSION = PROPERTIES.getProperty("version", "unknown");
// public static final String GROUP = PROPERTIES.getProperty("group", Version.class.getPackage().getName());
// public static final String NAME = PROPERTIES.getProperty("name", Version.class.getPackage().getName());
// public static final String DESCIPTION = PROPERTIES.getProperty("description", "");
//
// private static Properties load() {
// final Properties result = new Properties();
// final InputStream is = Version.class.getClassLoader().getResourceAsStream("org/echocat/gradle/plugins/golang/version.properties");
// if (is != null) {
// try (final Reader reader = new InputStreamReader(is, "UTF-8")) {
// result.load(reader);
// } catch (final IOException e) {
// throw new RuntimeException("Could not read version.properties.", e);
// } finally {
// closeQuietly(is);
// }
// }
// return result;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsFullReference.java
// public class VcsFullReference {
//
// @Nonnull
// private final VcsReference _reference;
// @Nonnull
// private final String _full;
//
// public VcsFullReference(@Nonnull VcsReference reference, @Nonnull String full) {
// _reference = reference;
// _full = full;
// }
//
// @Nonnull
// public VcsReference getReference() {
// return _reference;
// }
//
// @Nonnull
// public String getFull() {
// return _full;
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/ArtifactInfoCache.java
import com.google.gson.annotations.SerializedName;
import org.echocat.gradle.plugins.golang.Version;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsFullReference;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;
import java.util.TreeMap;
import static java.lang.System.currentTimeMillis;
public Map<String, Entry> getEntries() {
return _entries;
}
@Nullable
public Entry findEntryBy(@Nonnull String id) {
final Map<String, Entry> entries = _entries;
if (entries == null) {
return null;
}
return entries.get(id);
}
public void saveEntry(@Nonnull String id, @Nonnull Entry entry) {
if (_entries == null) {
_entries = new TreeMap<>();
}
_entries.put(id, entry);
}
public void saveEntry(@Nonnull String id, @Nullable String ref, @Nonnull String detailedRef, @Nonnegative long lastUpdatedMillis, boolean managed) {
final Entry entry = new Entry();
entry.setRef(ref);
entry.setDetailedRef(detailedRef);
entry.setLastUpdatedMillis(lastUpdatedMillis);
entry.setManaged(managed);
saveEntry(id, entry);
}
| public void saveEntry(@Nonnull RawVcsReference rawReference, @Nonnull VcsFullReference fullReference, boolean managed) { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/ArtifactInfoCache.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/Version.java
// public class Version {
//
// private static final Properties PROPERTIES = load();
//
// public static final String VERSION = PROPERTIES.getProperty("version", "unknown");
// public static final String GROUP = PROPERTIES.getProperty("group", Version.class.getPackage().getName());
// public static final String NAME = PROPERTIES.getProperty("name", Version.class.getPackage().getName());
// public static final String DESCIPTION = PROPERTIES.getProperty("description", "");
//
// private static Properties load() {
// final Properties result = new Properties();
// final InputStream is = Version.class.getClassLoader().getResourceAsStream("org/echocat/gradle/plugins/golang/version.properties");
// if (is != null) {
// try (final Reader reader = new InputStreamReader(is, "UTF-8")) {
// result.load(reader);
// } catch (final IOException e) {
// throw new RuntimeException("Could not read version.properties.", e);
// } finally {
// closeQuietly(is);
// }
// }
// return result;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsFullReference.java
// public class VcsFullReference {
//
// @Nonnull
// private final VcsReference _reference;
// @Nonnull
// private final String _full;
//
// public VcsFullReference(@Nonnull VcsReference reference, @Nonnull String full) {
// _reference = reference;
// _full = full;
// }
//
// @Nonnull
// public VcsReference getReference() {
// return _reference;
// }
//
// @Nonnull
// public String getFull() {
// return _full;
// }
//
// }
| import com.google.gson.annotations.SerializedName;
import org.echocat.gradle.plugins.golang.Version;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsFullReference;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;
import java.util.TreeMap;
import static java.lang.System.currentTimeMillis; |
public Map<String, Entry> getEntries() {
return _entries;
}
@Nullable
public Entry findEntryBy(@Nonnull String id) {
final Map<String, Entry> entries = _entries;
if (entries == null) {
return null;
}
return entries.get(id);
}
public void saveEntry(@Nonnull String id, @Nonnull Entry entry) {
if (_entries == null) {
_entries = new TreeMap<>();
}
_entries.put(id, entry);
}
public void saveEntry(@Nonnull String id, @Nullable String ref, @Nonnull String detailedRef, @Nonnegative long lastUpdatedMillis, boolean managed) {
final Entry entry = new Entry();
entry.setRef(ref);
entry.setDetailedRef(detailedRef);
entry.setLastUpdatedMillis(lastUpdatedMillis);
entry.setManaged(managed);
saveEntry(id, entry);
}
| // Path: src/main/java/org/echocat/gradle/plugins/golang/Version.java
// public class Version {
//
// private static final Properties PROPERTIES = load();
//
// public static final String VERSION = PROPERTIES.getProperty("version", "unknown");
// public static final String GROUP = PROPERTIES.getProperty("group", Version.class.getPackage().getName());
// public static final String NAME = PROPERTIES.getProperty("name", Version.class.getPackage().getName());
// public static final String DESCIPTION = PROPERTIES.getProperty("description", "");
//
// private static Properties load() {
// final Properties result = new Properties();
// final InputStream is = Version.class.getClassLoader().getResourceAsStream("org/echocat/gradle/plugins/golang/version.properties");
// if (is != null) {
// try (final Reader reader = new InputStreamReader(is, "UTF-8")) {
// result.load(reader);
// } catch (final IOException e) {
// throw new RuntimeException("Could not read version.properties.", e);
// } finally {
// closeQuietly(is);
// }
// }
// return result;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsFullReference.java
// public class VcsFullReference {
//
// @Nonnull
// private final VcsReference _reference;
// @Nonnull
// private final String _full;
//
// public VcsFullReference(@Nonnull VcsReference reference, @Nonnull String full) {
// _reference = reference;
// _full = full;
// }
//
// @Nonnull
// public VcsReference getReference() {
// return _reference;
// }
//
// @Nonnull
// public String getFull() {
// return _full;
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/ArtifactInfoCache.java
import com.google.gson.annotations.SerializedName;
import org.echocat.gradle.plugins.golang.Version;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsFullReference;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Map;
import java.util.TreeMap;
import static java.lang.System.currentTimeMillis;
public Map<String, Entry> getEntries() {
return _entries;
}
@Nullable
public Entry findEntryBy(@Nonnull String id) {
final Map<String, Entry> entries = _entries;
if (entries == null) {
return null;
}
return entries.get(id);
}
public void saveEntry(@Nonnull String id, @Nonnull Entry entry) {
if (_entries == null) {
_entries = new TreeMap<>();
}
_entries.put(id, entry);
}
public void saveEntry(@Nonnull String id, @Nullable String ref, @Nonnull String detailedRef, @Nonnegative long lastUpdatedMillis, boolean managed) {
final Entry entry = new Entry();
entry.setRef(ref);
entry.setDetailedRef(detailedRef);
entry.setLastUpdatedMillis(lastUpdatedMillis);
entry.setManaged(managed);
saveEntry(id, entry);
}
| public void saveEntry(@Nonnull RawVcsReference rawReference, @Nonnull VcsFullReference fullReference, boolean managed) { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/BaseVcsReference.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Immutable
// public final class UpdatePolicy implements Comparable<UpdatePolicy> {
//
// private static final UpdatePolicy ALWAYS = new UpdatePolicy(Type.always, 0);
// private static final UpdatePolicy NEVER = new UpdatePolicy(Type.never, 0);
// private static final UpdatePolicy DAILY = new UpdatePolicy(Type.daily, 60L * 24L);
//
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
//
// @Nonnull
// public static UpdatePolicy interval(@Nonnegative long intervalInMinutes) {
// return new UpdatePolicy(Type.interval, intervalInMinutes);
// }
//
// @Nonnull
// public static UpdatePolicy always() {
// return ALWAYS;
// }
//
// @Nonnull
// public static UpdatePolicy never() {
// return NEVER;
// }
//
// @Nonnull
// public static UpdatePolicy daily() {
// return DAILY;
// }
//
// @Nonnull
// private final Type _type;
// @Nonnegative
// private final long _intervalInMinutes;
//
// @Nonnull
// public static UpdatePolicy valueOf(@Nullable String value) throws IllegalArgumentException {
// if (isEmpty(value)) {
// return defaultUpdatePolicy();
// }
// final String[] parts = StringUtils.split(value, ':');
// final Type type;
// try {
// type = Type.valueOf(parts[0]);
// } catch (final IllegalArgumentException ignored) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// if (type == Type.interval) {
// if (parts.length != 2) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// try {
// final long intervalInMinutes = Long.valueOf(parts[1]);
// if (intervalInMinutes < 0) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// return interval(intervalInMinutes);
// } catch (final NumberFormatException ignored) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// }
// if (parts.length != 1) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// if (type == Type.never) {
// return never();
// }
// if (type == Type.always) {
// return always();
// }
// if (type == Type.daily) {
// return always();
// }
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
//
// private UpdatePolicy(@Nonnull Type type, @Nonnegative long intervalInMinutes) {
// _type = type;
// _intervalInMinutes = intervalInMinutes;
// }
//
// public boolean updateRequired(@Nonnegative long lastUpdatedMillis) {
// final Type type = _type;
// if (type == Type.never) {
// return false;
// }
// if (type == Type.always) {
// return true;
// }
// final long updateRequiredAfter = lastUpdatedMillis + MINUTES.toMillis(_intervalInMinutes);
// return updateRequiredAfter < currentTimeMillis();
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append(_type);
// if (_type == Type.interval) {
// sb.append(':').append(_intervalInMinutes);
// }
// return sb.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) { return true; }
// if (o == null || getClass() != o.getClass()) { return false; }
// final UpdatePolicy that = (UpdatePolicy) o;
// return _intervalInMinutes == that._intervalInMinutes &&
// _type == that._type;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(_type, _intervalInMinutes);
// }
//
// @Override
// public int compareTo(@Nonnull UpdatePolicy that) {
// if (_intervalInMinutes != that._intervalInMinutes) {
// return Long.compare(_intervalInMinutes, that._intervalInMinutes);
// }
// if (_type != that._type) {
// return _type.compareTo(that._type);
// }
// return 0;
// }
//
// private enum Type {
// interval,
// always,
// never,
// daily
// }
//
// }
| import org.echocat.gradle.plugins.golang.model.UpdatePolicy;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import java.util.Objects;
import static org.apache.commons.lang3.StringUtils.isNotEmpty; | package org.echocat.gradle.plugins.golang.vcs;
public abstract class BaseVcsReference {
@Nullable
private final VcsType _type;
@Nonnull
private final String _id;
@Nullable
private final URI _uri;
@Nullable
private final String _ref;
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Immutable
// public final class UpdatePolicy implements Comparable<UpdatePolicy> {
//
// private static final UpdatePolicy ALWAYS = new UpdatePolicy(Type.always, 0);
// private static final UpdatePolicy NEVER = new UpdatePolicy(Type.never, 0);
// private static final UpdatePolicy DAILY = new UpdatePolicy(Type.daily, 60L * 24L);
//
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
//
// @Nonnull
// public static UpdatePolicy interval(@Nonnegative long intervalInMinutes) {
// return new UpdatePolicy(Type.interval, intervalInMinutes);
// }
//
// @Nonnull
// public static UpdatePolicy always() {
// return ALWAYS;
// }
//
// @Nonnull
// public static UpdatePolicy never() {
// return NEVER;
// }
//
// @Nonnull
// public static UpdatePolicy daily() {
// return DAILY;
// }
//
// @Nonnull
// private final Type _type;
// @Nonnegative
// private final long _intervalInMinutes;
//
// @Nonnull
// public static UpdatePolicy valueOf(@Nullable String value) throws IllegalArgumentException {
// if (isEmpty(value)) {
// return defaultUpdatePolicy();
// }
// final String[] parts = StringUtils.split(value, ':');
// final Type type;
// try {
// type = Type.valueOf(parts[0]);
// } catch (final IllegalArgumentException ignored) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// if (type == Type.interval) {
// if (parts.length != 2) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// try {
// final long intervalInMinutes = Long.valueOf(parts[1]);
// if (intervalInMinutes < 0) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// return interval(intervalInMinutes);
// } catch (final NumberFormatException ignored) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// }
// if (parts.length != 1) {
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
// if (type == Type.never) {
// return never();
// }
// if (type == Type.always) {
// return always();
// }
// if (type == Type.daily) {
// return always();
// }
// throw new IllegalArgumentException("Illegal update policy: " + value);
// }
//
// private UpdatePolicy(@Nonnull Type type, @Nonnegative long intervalInMinutes) {
// _type = type;
// _intervalInMinutes = intervalInMinutes;
// }
//
// public boolean updateRequired(@Nonnegative long lastUpdatedMillis) {
// final Type type = _type;
// if (type == Type.never) {
// return false;
// }
// if (type == Type.always) {
// return true;
// }
// final long updateRequiredAfter = lastUpdatedMillis + MINUTES.toMillis(_intervalInMinutes);
// return updateRequiredAfter < currentTimeMillis();
// }
//
// @Override
// public String toString() {
// final StringBuilder sb = new StringBuilder();
// sb.append(_type);
// if (_type == Type.interval) {
// sb.append(':').append(_intervalInMinutes);
// }
// return sb.toString();
// }
//
// @Override
// public boolean equals(Object o) {
// if (this == o) { return true; }
// if (o == null || getClass() != o.getClass()) { return false; }
// final UpdatePolicy that = (UpdatePolicy) o;
// return _intervalInMinutes == that._intervalInMinutes &&
// _type == that._type;
// }
//
// @Override
// public int hashCode() {
// return Objects.hash(_type, _intervalInMinutes);
// }
//
// @Override
// public int compareTo(@Nonnull UpdatePolicy that) {
// if (_intervalInMinutes != that._intervalInMinutes) {
// return Long.compare(_intervalInMinutes, that._intervalInMinutes);
// }
// if (_type != that._type) {
// return _type.compareTo(that._type);
// }
// return 0;
// }
//
// private enum Type {
// interval,
// always,
// never,
// daily
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/BaseVcsReference.java
import org.echocat.gradle.plugins.golang.model.UpdatePolicy;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import java.util.Objects;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
package org.echocat.gradle.plugins.golang.vcs;
public abstract class BaseVcsReference {
@Nullable
private final VcsType _type;
@Nonnull
private final String _id;
@Nullable
private final URI _uri;
@Nullable
private final String _ref;
@Nonnull | private final UpdatePolicy _updatePolicy; |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/Settings.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/BeanUtils.java
// public static <T> void copyNonNulls(@Nonnull Class<T> type, @Nonnull T from, @Nonnull T to) {
// if (!type.isInstance(from)) {
// throw new IllegalArgumentException("From is not an instance of " + type.getName() + ". Got: " + from);
// }
// if (!type.isInstance(to)) {
// throw new IllegalArgumentException("To is not an instance of " + type.getName() + ". Got: " + to);
// }
// try {
// final BeanInfo info = Introspector.getBeanInfo(type);
// for (final PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
// final Method readMethod = descriptor.getReadMethod();
// final Method writeMethod = descriptor.getWriteMethod();
// if (readMethod != null && writeMethod != null) {
// final Object value = readMethod.invoke(from);
// if (value instanceof Map) {
// //noinspection unchecked
// final Map<Object, Object> properties = (Map<Object, Object>) readMethod.invoke(to);
// if (properties != null) {
// //noinspection unchecked
// properties.putAll((Map<Object, Object>) value);
// } else {
// writeMethod.invoke(to, value);
// }
// } else if (value != null) {
// writeMethod.invoke(to, value);
// }
// }
// }
// } catch (final Exception e) {
// throw new RuntimeException("Could not copy properties from " + from + " to " + to + ".", e);
// }
// }
| import org.gradle.api.Project;
import org.gradle.api.plugins.ExtensionAware;
import org.gradle.api.plugins.ExtensionContainer;
import javax.annotation.Nonnull;
import static org.echocat.gradle.plugins.golang.utils.BeanUtils.copyNonNulls; | }
@Nonnull
public ToolchainSettings getToolchain() {
return _toolchain;
}
@Nonnull
public DependenciesSettings getDependencies() {
return _dependencies;
}
@Nonnull
public TestingSettings getTesting() {
return _testing;
}
@Nonnull
public Project getProject() {
return _project;
}
@Nonnull
public Settings merge(@Nonnull Settings... with) {
final GolangSettings golang = new GolangSettings(false, _project);
final BuildSettings build = new BuildSettings(false, _project);
final ToolchainSettings toolchain = new ToolchainSettings(false, _project);
final DependenciesSettings dependencies = new DependenciesSettings(false, _project);
final TestingSettings testing = new TestingSettings(false, _project);
| // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/BeanUtils.java
// public static <T> void copyNonNulls(@Nonnull Class<T> type, @Nonnull T from, @Nonnull T to) {
// if (!type.isInstance(from)) {
// throw new IllegalArgumentException("From is not an instance of " + type.getName() + ". Got: " + from);
// }
// if (!type.isInstance(to)) {
// throw new IllegalArgumentException("To is not an instance of " + type.getName() + ". Got: " + to);
// }
// try {
// final BeanInfo info = Introspector.getBeanInfo(type);
// for (final PropertyDescriptor descriptor : info.getPropertyDescriptors()) {
// final Method readMethod = descriptor.getReadMethod();
// final Method writeMethod = descriptor.getWriteMethod();
// if (readMethod != null && writeMethod != null) {
// final Object value = readMethod.invoke(from);
// if (value instanceof Map) {
// //noinspection unchecked
// final Map<Object, Object> properties = (Map<Object, Object>) readMethod.invoke(to);
// if (properties != null) {
// //noinspection unchecked
// properties.putAll((Map<Object, Object>) value);
// } else {
// writeMethod.invoke(to, value);
// }
// } else if (value != null) {
// writeMethod.invoke(to, value);
// }
// }
// }
// } catch (final Exception e) {
// throw new RuntimeException("Could not copy properties from " + from + " to " + to + ".", e);
// }
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/Settings.java
import org.gradle.api.Project;
import org.gradle.api.plugins.ExtensionAware;
import org.gradle.api.plugins.ExtensionContainer;
import javax.annotation.Nonnull;
import static org.echocat.gradle.plugins.golang.utils.BeanUtils.copyNonNulls;
}
@Nonnull
public ToolchainSettings getToolchain() {
return _toolchain;
}
@Nonnull
public DependenciesSettings getDependencies() {
return _dependencies;
}
@Nonnull
public TestingSettings getTesting() {
return _testing;
}
@Nonnull
public Project getProject() {
return _project;
}
@Nonnull
public Settings merge(@Nonnull Settings... with) {
final GolangSettings golang = new GolangSettings(false, _project);
final BuildSettings build = new BuildSettings(false, _project);
final ToolchainSettings toolchain = new ToolchainSettings(false, _project);
final DependenciesSettings dependencies = new DependenciesSettings(false, _project);
final TestingSettings testing = new TestingSettings(false, _project);
| copyNonNulls(GolangSettings.class, _golang, golang); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/testing/TestReportOptimizer.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/Settings.java
// public class Settings {
//
// @Nonnull
// private final Project _project;
// @Nonnull
// private final GolangSettings _golang;
// @Nonnull
// private final BuildSettings _build;
// @Nonnull
// private final ToolchainSettings _toolchain;
// @Nonnull
// private final DependenciesSettings _dependencies;
// @Nonnull
// private final TestingSettings _testing;
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container) {
// _project = project;
// _golang = container.getByType(GolangSettings.class);
// if (!(_golang instanceof ExtensionAware)) {
// throw new IllegalStateException("golang instance (" + _golang + ") of provided extension container (" + container + ") is not an instance of " + ExtensionAware.class.getName() + ".");
// }
// final ExtensionContainer globalExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = globalExtensions.getByType(BuildSettings.class);
// _toolchain = globalExtensions.getByType(ToolchainSettings.class);
// _dependencies = globalExtensions.getByType(DependenciesSettings.class);
// _testing = globalExtensions.getByType(TestingSettings.class);
// }
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container, boolean init) {
// _project = project;
// _golang = container.create("golang", GolangSettings.class, init, project);
// final ExtensionContainer taskExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = taskExtensions.create("build", BuildSettings.class, init, project);
// _toolchain = taskExtensions.create("toolchain", ToolchainSettings.class, init, project);
// _dependencies = taskExtensions.create("dependencies", DependenciesSettings.class, init, project);
// _testing = taskExtensions.create("testing", TestingSettings.class, init, project);
// }
//
// public Settings(@Nonnull Project project, @Nonnull GolangSettings golang, @Nonnull BuildSettings build, @Nonnull ToolchainSettings toolchain, @Nonnull DependenciesSettings dependencies, @Nonnull TestingSettings testing) {
// _project = project;
// _golang = golang;
// _build = build;
// _toolchain = toolchain;
// _dependencies = dependencies;
// _testing = testing;
// }
//
// @Nonnull
// public GolangSettings getGolang() {
// return _golang;
// }
//
// @Nonnull
// public BuildSettings getBuild() {
// return _build;
// }
//
// @Nonnull
// public ToolchainSettings getToolchain() {
// return _toolchain;
// }
//
// @Nonnull
// public DependenciesSettings getDependencies() {
// return _dependencies;
// }
//
// @Nonnull
// public TestingSettings getTesting() {
// return _testing;
// }
//
// @Nonnull
// public Project getProject() {
// return _project;
// }
//
// @Nonnull
// public Settings merge(@Nonnull Settings... with) {
// final GolangSettings golang = new GolangSettings(false, _project);
// final BuildSettings build = new BuildSettings(false, _project);
// final ToolchainSettings toolchain = new ToolchainSettings(false, _project);
// final DependenciesSettings dependencies = new DependenciesSettings(false, _project);
// final TestingSettings testing = new TestingSettings(false, _project);
//
// copyNonNulls(GolangSettings.class, _golang, golang);
// copyNonNulls(BuildSettings.class, _build, build);
// copyNonNulls(ToolchainSettings.class, _toolchain, toolchain);
// copyNonNulls(DependenciesSettings.class, _dependencies, dependencies);
// copyNonNulls(TestingSettings.class, _testing, testing);
//
// for (final Settings source : with) {
// copyNonNulls(GolangSettings.class, source.getGolang(), golang);
// copyNonNulls(BuildSettings.class, source.getBuild(), build);
// copyNonNulls(ToolchainSettings.class, source.getToolchain(), toolchain);
// copyNonNulls(DependenciesSettings.class, source.getDependencies(), dependencies);
// copyNonNulls(TestingSettings.class, source.getTesting(), testing);
// }
//
// return new Settings(_project, golang, build, toolchain, dependencies, testing);
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/ProjectEnabled.java
// public interface ProjectEnabled {
//
// @Nonnull
// public Project getProject();
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/ProjectsAndSettingsEnabledSupport.java
// public abstract class ProjectsAndSettingsEnabledSupport extends SettingsEnabledSupport {
//
// @Nonnull
// private final Project _project;
//
// public ProjectsAndSettingsEnabledSupport(@Nonnull Project project, @Nonnull Settings settings) {
// super(settings);
// _project = project;
// }
//
// public <T extends SettingsEnabled & ProjectEnabled> ProjectsAndSettingsEnabledSupport(@Nonnull T source) {
// this(source.getProject(), source.getSettings());
// }
//
// @Nonnull
// public Project getProject() {
// return _project;
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/SettingsEnabled.java
// public interface SettingsEnabled {
//
// @Nonnull
// public Settings getSettings();
//
// }
| import org.echocat.gradle.plugins.golang.model.Settings;
import org.echocat.gradle.plugins.golang.utils.ProjectEnabled;
import org.echocat.gradle.plugins.golang.utils.ProjectsAndSettingsEnabledSupport;
import org.echocat.gradle.plugins.golang.utils.SettingsEnabled;
import org.gradle.api.Project;
import javax.annotation.Nonnull; | package org.echocat.gradle.plugins.golang.testing;
public class TestReportOptimizer extends ProjectsAndSettingsEnabledSupport {
public TestReportOptimizer(@Nonnull Project project, @Nonnull Settings settings) {
super(project, settings);
}
| // Path: src/main/java/org/echocat/gradle/plugins/golang/model/Settings.java
// public class Settings {
//
// @Nonnull
// private final Project _project;
// @Nonnull
// private final GolangSettings _golang;
// @Nonnull
// private final BuildSettings _build;
// @Nonnull
// private final ToolchainSettings _toolchain;
// @Nonnull
// private final DependenciesSettings _dependencies;
// @Nonnull
// private final TestingSettings _testing;
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container) {
// _project = project;
// _golang = container.getByType(GolangSettings.class);
// if (!(_golang instanceof ExtensionAware)) {
// throw new IllegalStateException("golang instance (" + _golang + ") of provided extension container (" + container + ") is not an instance of " + ExtensionAware.class.getName() + ".");
// }
// final ExtensionContainer globalExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = globalExtensions.getByType(BuildSettings.class);
// _toolchain = globalExtensions.getByType(ToolchainSettings.class);
// _dependencies = globalExtensions.getByType(DependenciesSettings.class);
// _testing = globalExtensions.getByType(TestingSettings.class);
// }
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container, boolean init) {
// _project = project;
// _golang = container.create("golang", GolangSettings.class, init, project);
// final ExtensionContainer taskExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = taskExtensions.create("build", BuildSettings.class, init, project);
// _toolchain = taskExtensions.create("toolchain", ToolchainSettings.class, init, project);
// _dependencies = taskExtensions.create("dependencies", DependenciesSettings.class, init, project);
// _testing = taskExtensions.create("testing", TestingSettings.class, init, project);
// }
//
// public Settings(@Nonnull Project project, @Nonnull GolangSettings golang, @Nonnull BuildSettings build, @Nonnull ToolchainSettings toolchain, @Nonnull DependenciesSettings dependencies, @Nonnull TestingSettings testing) {
// _project = project;
// _golang = golang;
// _build = build;
// _toolchain = toolchain;
// _dependencies = dependencies;
// _testing = testing;
// }
//
// @Nonnull
// public GolangSettings getGolang() {
// return _golang;
// }
//
// @Nonnull
// public BuildSettings getBuild() {
// return _build;
// }
//
// @Nonnull
// public ToolchainSettings getToolchain() {
// return _toolchain;
// }
//
// @Nonnull
// public DependenciesSettings getDependencies() {
// return _dependencies;
// }
//
// @Nonnull
// public TestingSettings getTesting() {
// return _testing;
// }
//
// @Nonnull
// public Project getProject() {
// return _project;
// }
//
// @Nonnull
// public Settings merge(@Nonnull Settings... with) {
// final GolangSettings golang = new GolangSettings(false, _project);
// final BuildSettings build = new BuildSettings(false, _project);
// final ToolchainSettings toolchain = new ToolchainSettings(false, _project);
// final DependenciesSettings dependencies = new DependenciesSettings(false, _project);
// final TestingSettings testing = new TestingSettings(false, _project);
//
// copyNonNulls(GolangSettings.class, _golang, golang);
// copyNonNulls(BuildSettings.class, _build, build);
// copyNonNulls(ToolchainSettings.class, _toolchain, toolchain);
// copyNonNulls(DependenciesSettings.class, _dependencies, dependencies);
// copyNonNulls(TestingSettings.class, _testing, testing);
//
// for (final Settings source : with) {
// copyNonNulls(GolangSettings.class, source.getGolang(), golang);
// copyNonNulls(BuildSettings.class, source.getBuild(), build);
// copyNonNulls(ToolchainSettings.class, source.getToolchain(), toolchain);
// copyNonNulls(DependenciesSettings.class, source.getDependencies(), dependencies);
// copyNonNulls(TestingSettings.class, source.getTesting(), testing);
// }
//
// return new Settings(_project, golang, build, toolchain, dependencies, testing);
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/ProjectEnabled.java
// public interface ProjectEnabled {
//
// @Nonnull
// public Project getProject();
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/ProjectsAndSettingsEnabledSupport.java
// public abstract class ProjectsAndSettingsEnabledSupport extends SettingsEnabledSupport {
//
// @Nonnull
// private final Project _project;
//
// public ProjectsAndSettingsEnabledSupport(@Nonnull Project project, @Nonnull Settings settings) {
// super(settings);
// _project = project;
// }
//
// public <T extends SettingsEnabled & ProjectEnabled> ProjectsAndSettingsEnabledSupport(@Nonnull T source) {
// this(source.getProject(), source.getSettings());
// }
//
// @Nonnull
// public Project getProject() {
// return _project;
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/SettingsEnabled.java
// public interface SettingsEnabled {
//
// @Nonnull
// public Settings getSettings();
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/testing/TestReportOptimizer.java
import org.echocat.gradle.plugins.golang.model.Settings;
import org.echocat.gradle.plugins.golang.utils.ProjectEnabled;
import org.echocat.gradle.plugins.golang.utils.ProjectsAndSettingsEnabledSupport;
import org.echocat.gradle.plugins.golang.utils.SettingsEnabled;
import org.gradle.api.Project;
import javax.annotation.Nonnull;
package org.echocat.gradle.plugins.golang.testing;
public class TestReportOptimizer extends ProjectsAndSettingsEnabledSupport {
public TestReportOptimizer(@Nonnull Project project, @Nonnull Settings settings) {
super(project, settings);
}
| public <T extends SettingsEnabled & ProjectEnabled> TestReportOptimizer(@Nonnull T source) { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/testing/TestReportOptimizer.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/model/Settings.java
// public class Settings {
//
// @Nonnull
// private final Project _project;
// @Nonnull
// private final GolangSettings _golang;
// @Nonnull
// private final BuildSettings _build;
// @Nonnull
// private final ToolchainSettings _toolchain;
// @Nonnull
// private final DependenciesSettings _dependencies;
// @Nonnull
// private final TestingSettings _testing;
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container) {
// _project = project;
// _golang = container.getByType(GolangSettings.class);
// if (!(_golang instanceof ExtensionAware)) {
// throw new IllegalStateException("golang instance (" + _golang + ") of provided extension container (" + container + ") is not an instance of " + ExtensionAware.class.getName() + ".");
// }
// final ExtensionContainer globalExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = globalExtensions.getByType(BuildSettings.class);
// _toolchain = globalExtensions.getByType(ToolchainSettings.class);
// _dependencies = globalExtensions.getByType(DependenciesSettings.class);
// _testing = globalExtensions.getByType(TestingSettings.class);
// }
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container, boolean init) {
// _project = project;
// _golang = container.create("golang", GolangSettings.class, init, project);
// final ExtensionContainer taskExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = taskExtensions.create("build", BuildSettings.class, init, project);
// _toolchain = taskExtensions.create("toolchain", ToolchainSettings.class, init, project);
// _dependencies = taskExtensions.create("dependencies", DependenciesSettings.class, init, project);
// _testing = taskExtensions.create("testing", TestingSettings.class, init, project);
// }
//
// public Settings(@Nonnull Project project, @Nonnull GolangSettings golang, @Nonnull BuildSettings build, @Nonnull ToolchainSettings toolchain, @Nonnull DependenciesSettings dependencies, @Nonnull TestingSettings testing) {
// _project = project;
// _golang = golang;
// _build = build;
// _toolchain = toolchain;
// _dependencies = dependencies;
// _testing = testing;
// }
//
// @Nonnull
// public GolangSettings getGolang() {
// return _golang;
// }
//
// @Nonnull
// public BuildSettings getBuild() {
// return _build;
// }
//
// @Nonnull
// public ToolchainSettings getToolchain() {
// return _toolchain;
// }
//
// @Nonnull
// public DependenciesSettings getDependencies() {
// return _dependencies;
// }
//
// @Nonnull
// public TestingSettings getTesting() {
// return _testing;
// }
//
// @Nonnull
// public Project getProject() {
// return _project;
// }
//
// @Nonnull
// public Settings merge(@Nonnull Settings... with) {
// final GolangSettings golang = new GolangSettings(false, _project);
// final BuildSettings build = new BuildSettings(false, _project);
// final ToolchainSettings toolchain = new ToolchainSettings(false, _project);
// final DependenciesSettings dependencies = new DependenciesSettings(false, _project);
// final TestingSettings testing = new TestingSettings(false, _project);
//
// copyNonNulls(GolangSettings.class, _golang, golang);
// copyNonNulls(BuildSettings.class, _build, build);
// copyNonNulls(ToolchainSettings.class, _toolchain, toolchain);
// copyNonNulls(DependenciesSettings.class, _dependencies, dependencies);
// copyNonNulls(TestingSettings.class, _testing, testing);
//
// for (final Settings source : with) {
// copyNonNulls(GolangSettings.class, source.getGolang(), golang);
// copyNonNulls(BuildSettings.class, source.getBuild(), build);
// copyNonNulls(ToolchainSettings.class, source.getToolchain(), toolchain);
// copyNonNulls(DependenciesSettings.class, source.getDependencies(), dependencies);
// copyNonNulls(TestingSettings.class, source.getTesting(), testing);
// }
//
// return new Settings(_project, golang, build, toolchain, dependencies, testing);
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/ProjectEnabled.java
// public interface ProjectEnabled {
//
// @Nonnull
// public Project getProject();
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/ProjectsAndSettingsEnabledSupport.java
// public abstract class ProjectsAndSettingsEnabledSupport extends SettingsEnabledSupport {
//
// @Nonnull
// private final Project _project;
//
// public ProjectsAndSettingsEnabledSupport(@Nonnull Project project, @Nonnull Settings settings) {
// super(settings);
// _project = project;
// }
//
// public <T extends SettingsEnabled & ProjectEnabled> ProjectsAndSettingsEnabledSupport(@Nonnull T source) {
// this(source.getProject(), source.getSettings());
// }
//
// @Nonnull
// public Project getProject() {
// return _project;
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/SettingsEnabled.java
// public interface SettingsEnabled {
//
// @Nonnull
// public Settings getSettings();
//
// }
| import org.echocat.gradle.plugins.golang.model.Settings;
import org.echocat.gradle.plugins.golang.utils.ProjectEnabled;
import org.echocat.gradle.plugins.golang.utils.ProjectsAndSettingsEnabledSupport;
import org.echocat.gradle.plugins.golang.utils.SettingsEnabled;
import org.gradle.api.Project;
import javax.annotation.Nonnull; | package org.echocat.gradle.plugins.golang.testing;
public class TestReportOptimizer extends ProjectsAndSettingsEnabledSupport {
public TestReportOptimizer(@Nonnull Project project, @Nonnull Settings settings) {
super(project, settings);
}
| // Path: src/main/java/org/echocat/gradle/plugins/golang/model/Settings.java
// public class Settings {
//
// @Nonnull
// private final Project _project;
// @Nonnull
// private final GolangSettings _golang;
// @Nonnull
// private final BuildSettings _build;
// @Nonnull
// private final ToolchainSettings _toolchain;
// @Nonnull
// private final DependenciesSettings _dependencies;
// @Nonnull
// private final TestingSettings _testing;
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container) {
// _project = project;
// _golang = container.getByType(GolangSettings.class);
// if (!(_golang instanceof ExtensionAware)) {
// throw new IllegalStateException("golang instance (" + _golang + ") of provided extension container (" + container + ") is not an instance of " + ExtensionAware.class.getName() + ".");
// }
// final ExtensionContainer globalExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = globalExtensions.getByType(BuildSettings.class);
// _toolchain = globalExtensions.getByType(ToolchainSettings.class);
// _dependencies = globalExtensions.getByType(DependenciesSettings.class);
// _testing = globalExtensions.getByType(TestingSettings.class);
// }
//
// public Settings(@Nonnull Project project, @Nonnull ExtensionContainer container, boolean init) {
// _project = project;
// _golang = container.create("golang", GolangSettings.class, init, project);
// final ExtensionContainer taskExtensions = ((ExtensionAware) _golang).getExtensions();
// _build = taskExtensions.create("build", BuildSettings.class, init, project);
// _toolchain = taskExtensions.create("toolchain", ToolchainSettings.class, init, project);
// _dependencies = taskExtensions.create("dependencies", DependenciesSettings.class, init, project);
// _testing = taskExtensions.create("testing", TestingSettings.class, init, project);
// }
//
// public Settings(@Nonnull Project project, @Nonnull GolangSettings golang, @Nonnull BuildSettings build, @Nonnull ToolchainSettings toolchain, @Nonnull DependenciesSettings dependencies, @Nonnull TestingSettings testing) {
// _project = project;
// _golang = golang;
// _build = build;
// _toolchain = toolchain;
// _dependencies = dependencies;
// _testing = testing;
// }
//
// @Nonnull
// public GolangSettings getGolang() {
// return _golang;
// }
//
// @Nonnull
// public BuildSettings getBuild() {
// return _build;
// }
//
// @Nonnull
// public ToolchainSettings getToolchain() {
// return _toolchain;
// }
//
// @Nonnull
// public DependenciesSettings getDependencies() {
// return _dependencies;
// }
//
// @Nonnull
// public TestingSettings getTesting() {
// return _testing;
// }
//
// @Nonnull
// public Project getProject() {
// return _project;
// }
//
// @Nonnull
// public Settings merge(@Nonnull Settings... with) {
// final GolangSettings golang = new GolangSettings(false, _project);
// final BuildSettings build = new BuildSettings(false, _project);
// final ToolchainSettings toolchain = new ToolchainSettings(false, _project);
// final DependenciesSettings dependencies = new DependenciesSettings(false, _project);
// final TestingSettings testing = new TestingSettings(false, _project);
//
// copyNonNulls(GolangSettings.class, _golang, golang);
// copyNonNulls(BuildSettings.class, _build, build);
// copyNonNulls(ToolchainSettings.class, _toolchain, toolchain);
// copyNonNulls(DependenciesSettings.class, _dependencies, dependencies);
// copyNonNulls(TestingSettings.class, _testing, testing);
//
// for (final Settings source : with) {
// copyNonNulls(GolangSettings.class, source.getGolang(), golang);
// copyNonNulls(BuildSettings.class, source.getBuild(), build);
// copyNonNulls(ToolchainSettings.class, source.getToolchain(), toolchain);
// copyNonNulls(DependenciesSettings.class, source.getDependencies(), dependencies);
// copyNonNulls(TestingSettings.class, source.getTesting(), testing);
// }
//
// return new Settings(_project, golang, build, toolchain, dependencies, testing);
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/ProjectEnabled.java
// public interface ProjectEnabled {
//
// @Nonnull
// public Project getProject();
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/ProjectsAndSettingsEnabledSupport.java
// public abstract class ProjectsAndSettingsEnabledSupport extends SettingsEnabledSupport {
//
// @Nonnull
// private final Project _project;
//
// public ProjectsAndSettingsEnabledSupport(@Nonnull Project project, @Nonnull Settings settings) {
// super(settings);
// _project = project;
// }
//
// public <T extends SettingsEnabled & ProjectEnabled> ProjectsAndSettingsEnabledSupport(@Nonnull T source) {
// this(source.getProject(), source.getSettings());
// }
//
// @Nonnull
// public Project getProject() {
// return _project;
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/SettingsEnabled.java
// public interface SettingsEnabled {
//
// @Nonnull
// public Settings getSettings();
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/testing/TestReportOptimizer.java
import org.echocat.gradle.plugins.golang.model.Settings;
import org.echocat.gradle.plugins.golang.utils.ProjectEnabled;
import org.echocat.gradle.plugins.golang.utils.ProjectsAndSettingsEnabledSupport;
import org.echocat.gradle.plugins.golang.utils.SettingsEnabled;
import org.gradle.api.Project;
import javax.annotation.Nonnull;
package org.echocat.gradle.plugins.golang.testing;
public class TestReportOptimizer extends ProjectsAndSettingsEnabledSupport {
public TestReportOptimizer(@Nonnull Project project, @Nonnull Settings settings) {
super(project, settings);
}
| public <T extends SettingsEnabled & ProjectEnabled> TestReportOptimizer(@Nonnull T source) { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/ToolchainSettings.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// @Nullable
// public static Path toPath(@Nullable String plain) {
// return plain != null ? Paths.get(plain) : null;
// }
| import org.gradle.api.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.nio.file.Files.isExecutable;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.model.OperatingSystem.WINDOWS;
import static org.echocat.gradle.plugins.golang.model.OperatingSystem.currentOperatingSystem;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.toPath; | _goversion = "go1.8";
_downloadUriRoot = URI.create("https://storage.googleapis.com/golang/");
}
}
public Boolean getForceBuildToolchain() {
return _forceBuildToolchain;
}
public void setForceBuildToolchain(Boolean forceBuildToolchain) {
_forceBuildToolchain = forceBuildToolchain;
}
public String getGoversion() {
return _goversion;
}
public void setGoversion(String goversion) {
_goversion = goversion;
}
public Path getGoroot() {
return _goroot;
}
public void setGoroot(Path goroot) {
_goroot = goroot;
}
public void setGoroot(String goroot) { | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// @Nullable
// public static Path toPath(@Nullable String plain) {
// return plain != null ? Paths.get(plain) : null;
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/ToolchainSettings.java
import org.gradle.api.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.nio.file.Files.isExecutable;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.model.OperatingSystem.WINDOWS;
import static org.echocat.gradle.plugins.golang.model.OperatingSystem.currentOperatingSystem;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.toPath;
_goversion = "go1.8";
_downloadUriRoot = URI.create("https://storage.googleapis.com/golang/");
}
}
public Boolean getForceBuildToolchain() {
return _forceBuildToolchain;
}
public void setForceBuildToolchain(Boolean forceBuildToolchain) {
_forceBuildToolchain = forceBuildToolchain;
}
public String getGoversion() {
return _goversion;
}
public void setGoversion(String goversion) {
_goversion = goversion;
}
public Path getGoroot() {
return _goroot;
}
public void setGoroot(Path goroot) {
_goroot = goroot;
}
public void setGoroot(String goroot) { | setGoroot(toPath(goroot)); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/ToolchainSettings.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// @Nullable
// public static Path toPath(@Nullable String plain) {
// return plain != null ? Paths.get(plain) : null;
// }
| import org.gradle.api.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.nio.file.Files.isExecutable;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.model.OperatingSystem.WINDOWS;
import static org.echocat.gradle.plugins.golang.model.OperatingSystem.currentOperatingSystem;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.toPath; | }
public void setBootstrapGoroot(Path bootstrapGoroot) {
_bootstrapGoroot = bootstrapGoroot;
}
public void setBootstrapGoroot(String bootstrapGoroot) {
setBootstrapGoroot(toPath(bootstrapGoroot));
}
public URI getDownloadUriRoot() {
return _downloadUriRoot;
}
public void setDownloadUriRoot(URI downloadUriRoot) {
_downloadUriRoot = downloadUriRoot;
}
public void setDownloadUriRoot(String downloadUriRoot) {
setDownloadUriRoot(downloadUriRoot != null ? URI.create(downloadUriRoot) : null);
}
@Nullable
public String goBinaryVersionOf(Path goroot) {
final Path goBinary = goBinaryOf(goroot);
if (!isExecutable(goBinary)) {
return null;
}
final String stdout;
try { | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/Executor.java
// @Nonnull
// public static Executor executor(@Nonnull String executable) {
// return executor(Paths.get(executable).toAbsolutePath());
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/FileUtils.java
// @Nullable
// public static Path toPath(@Nullable String plain) {
// return plain != null ? Paths.get(plain) : null;
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/ToolchainSettings.java
import org.gradle.api.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.inject.Inject;
import java.io.IOException;
import java.net.URI;
import java.nio.file.Path;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.nio.file.Files.isExecutable;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.model.OperatingSystem.WINDOWS;
import static org.echocat.gradle.plugins.golang.model.OperatingSystem.currentOperatingSystem;
import static org.echocat.gradle.plugins.golang.utils.Executor.executor;
import static org.echocat.gradle.plugins.golang.utils.FileUtils.toPath;
}
public void setBootstrapGoroot(Path bootstrapGoroot) {
_bootstrapGoroot = bootstrapGoroot;
}
public void setBootstrapGoroot(String bootstrapGoroot) {
setBootstrapGoroot(toPath(bootstrapGoroot));
}
public URI getDownloadUriRoot() {
return _downloadUriRoot;
}
public void setDownloadUriRoot(URI downloadUriRoot) {
_downloadUriRoot = downloadUriRoot;
}
public void setDownloadUriRoot(String downloadUriRoot) {
setDownloadUriRoot(downloadUriRoot != null ? URI.create(downloadUriRoot) : null);
}
@Nullable
public String goBinaryVersionOf(Path goroot) {
final Path goBinary = goBinaryOf(goroot);
if (!isExecutable(goBinary)) {
return null;
}
final String stdout;
try { | stdout = executor(goBinary) |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/GoogleGolangOrgVcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git; | package org.echocat.gradle.plugins.golang.vcs.isps;
public class GoogleGolangOrgVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
private static final Logger LOGGER = LoggerFactory.getLogger(GoogleGolangOrgVcsRepositoryProvider.class);
protected static final Pattern REF_PATTERN = compile("^refs/(?:heads|tags)/v(?<version>[0-9]{1,9}(?:\\.[0-9]{1,9}(?:\\.[0-9]{1,9})?)?)$");
public GoogleGolangOrgVcsRepositoryProvider() {
super("google.golang.org/", compile("^(?<root>google.golang\\.org/(?<repo>[A-Za-z0-9_.\\-]+))(?<subPath>/[A-Za-z0-9_.\\-]+)*$"));
}
@Nonnull
@Override | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/GoogleGolangOrgVcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
package org.echocat.gradle.plugins.golang.vcs.isps;
public class GoogleGolangOrgVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
private static final Logger LOGGER = LoggerFactory.getLogger(GoogleGolangOrgVcsRepositoryProvider.class);
protected static final Pattern REF_PATTERN = compile("^refs/(?:heads|tags)/v(?<version>[0-9]{1,9}(?:\\.[0-9]{1,9}(?:\\.[0-9]{1,9})?)?)$");
public GoogleGolangOrgVcsRepositoryProvider() {
super("google.golang.org/", compile("^(?<root>google.golang\\.org/(?<repo>[A-Za-z0-9_.\\-]+))(?<subPath>/[A-Za-z0-9_.\\-]+)*$"));
}
@Nonnull
@Override | protected String rootFor(@Nonnull Matcher matcher, @Nonnull RawVcsReference rawReference) throws VcsException { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/GoogleGolangOrgVcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git; | package org.echocat.gradle.plugins.golang.vcs.isps;
public class GoogleGolangOrgVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
private static final Logger LOGGER = LoggerFactory.getLogger(GoogleGolangOrgVcsRepositoryProvider.class);
protected static final Pattern REF_PATTERN = compile("^refs/(?:heads|tags)/v(?<version>[0-9]{1,9}(?:\\.[0-9]{1,9}(?:\\.[0-9]{1,9})?)?)$");
public GoogleGolangOrgVcsRepositoryProvider() {
super("google.golang.org/", compile("^(?<root>google.golang\\.org/(?<repo>[A-Za-z0-9_.\\-]+))(?<subPath>/[A-Za-z0-9_.\\-]+)*$"));
}
@Nonnull
@Override | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/GoogleGolangOrgVcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.util.regex.Pattern.compile;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
package org.echocat.gradle.plugins.golang.vcs.isps;
public class GoogleGolangOrgVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
private static final Logger LOGGER = LoggerFactory.getLogger(GoogleGolangOrgVcsRepositoryProvider.class);
protected static final Pattern REF_PATTERN = compile("^refs/(?:heads|tags)/v(?<version>[0-9]{1,9}(?:\\.[0-9]{1,9}(?:\\.[0-9]{1,9})?)?)$");
public GoogleGolangOrgVcsRepositoryProvider() {
super("google.golang.org/", compile("^(?<root>google.golang\\.org/(?<repo>[A-Za-z0-9_.\\-]+))(?<subPath>/[A-Za-z0-9_.\\-]+)*$"));
}
@Nonnull
@Override | protected String rootFor(@Nonnull Matcher matcher, @Nonnull RawVcsReference rawReference) throws VcsException { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/git/GitVcsUri.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public class VcsReference extends BaseVcsReference {
//
// @Nullable
// private final String _subPath;
//
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull String plain, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// super(type, id, URI.create(plain), ref, defaultUpdatePolicy());
// //noinspection ConstantConditions
// if (type == null) {
// throw new VcsValidationException("Empty type provided.");
// }
// if (isEmpty(plain)) {
// throw new VcsValidationException("Empty uri provided.");
// }
// _subPath = subPath;
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull URI uri, @Nullable String ref, @Nonnull UpdatePolicy updatePolicy, @Nullable String subPath) {
// super(type, id, uri, ref, updatePolicy);
// //noinspection ConstantConditions
// if (type == null) {
// throw new NullPointerException("type is null");
// }
// //noinspection ConstantConditions
// if (uri == null) {
// throw new NullPointerException("uri is null");
// }
// _subPath = subPath;
// }
//
// @Nonnull
// @Override
// public VcsType getType() {
// //noinspection ConstantConditions
// return super.getType();
// }
//
// @Override
// @Nonnull
// public URI getUri() {
// //noinspection ConstantConditions
// return super.getUri();
// }
//
// @Nullable
// public String getSubPath() {
// return _subPath;
// }
// }
| import org.echocat.gradle.plugins.golang.vcs.VcsReference;
import javax.annotation.Nonnull;
import java.net.URI;
import java.util.Objects;
import java.util.regex.Matcher;
import static java.net.URI.create; | package org.echocat.gradle.plugins.golang.vcs.git;
public class GitVcsUri {
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public class VcsReference extends BaseVcsReference {
//
// @Nullable
// private final String _subPath;
//
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull String plain, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// super(type, id, URI.create(plain), ref, defaultUpdatePolicy());
// //noinspection ConstantConditions
// if (type == null) {
// throw new VcsValidationException("Empty type provided.");
// }
// if (isEmpty(plain)) {
// throw new VcsValidationException("Empty uri provided.");
// }
// _subPath = subPath;
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull URI uri, @Nullable String ref, @Nonnull UpdatePolicy updatePolicy, @Nullable String subPath) {
// super(type, id, uri, ref, updatePolicy);
// //noinspection ConstantConditions
// if (type == null) {
// throw new NullPointerException("type is null");
// }
// //noinspection ConstantConditions
// if (uri == null) {
// throw new NullPointerException("uri is null");
// }
// _subPath = subPath;
// }
//
// @Nonnull
// @Override
// public VcsType getType() {
// //noinspection ConstantConditions
// return super.getType();
// }
//
// @Override
// @Nonnull
// public URI getUri() {
// //noinspection ConstantConditions
// return super.getUri();
// }
//
// @Nullable
// public String getSubPath() {
// return _subPath;
// }
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/git/GitVcsUri.java
import org.echocat.gradle.plugins.golang.vcs.VcsReference;
import javax.annotation.Nonnull;
import java.net.URI;
import java.util.Objects;
import java.util.regex.Matcher;
import static java.net.URI.create;
package org.echocat.gradle.plugins.golang.vcs.git;
public class GitVcsUri {
@Nonnull | public static GitVcsUri gitVcsUriFor(@Nonnull VcsReference reference) { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/VcsRepositoryInfo.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/Version.java
// public class Version {
//
// private static final Properties PROPERTIES = load();
//
// public static final String VERSION = PROPERTIES.getProperty("version", "unknown");
// public static final String GROUP = PROPERTIES.getProperty("group", Version.class.getPackage().getName());
// public static final String NAME = PROPERTIES.getProperty("name", Version.class.getPackage().getName());
// public static final String DESCIPTION = PROPERTIES.getProperty("description", "");
//
// private static Properties load() {
// final Properties result = new Properties();
// final InputStream is = Version.class.getClassLoader().getResourceAsStream("org/echocat/gradle/plugins/golang/version.properties");
// if (is != null) {
// try (final Reader reader = new InputStreamReader(is, "UTF-8")) {
// result.load(reader);
// } catch (final IOException e) {
// throw new RuntimeException("Could not read version.properties.", e);
// } finally {
// closeQuietly(is);
// }
// }
// return result;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
| import com.google.gson.annotations.SerializedName;
import org.echocat.gradle.plugins.golang.Version;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import java.net.URI; | package org.echocat.gradle.plugins.golang.model;
public class VcsRepositoryInfo {
@SerializedName("creator") | // Path: src/main/java/org/echocat/gradle/plugins/golang/Version.java
// public class Version {
//
// private static final Properties PROPERTIES = load();
//
// public static final String VERSION = PROPERTIES.getProperty("version", "unknown");
// public static final String GROUP = PROPERTIES.getProperty("group", Version.class.getPackage().getName());
// public static final String NAME = PROPERTIES.getProperty("name", Version.class.getPackage().getName());
// public static final String DESCIPTION = PROPERTIES.getProperty("description", "");
//
// private static Properties load() {
// final Properties result = new Properties();
// final InputStream is = Version.class.getClassLoader().getResourceAsStream("org/echocat/gradle/plugins/golang/version.properties");
// if (is != null) {
// try (final Reader reader = new InputStreamReader(is, "UTF-8")) {
// result.load(reader);
// } catch (final IOException e) {
// throw new RuntimeException("Could not read version.properties.", e);
// } finally {
// closeQuietly(is);
// }
// }
// return result;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/VcsRepositoryInfo.java
import com.google.gson.annotations.SerializedName;
import org.echocat.gradle.plugins.golang.Version;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import java.net.URI;
package org.echocat.gradle.plugins.golang.model;
public class VcsRepositoryInfo {
@SerializedName("creator") | private String _creator = Version.NAME + " " + Version.VERSION; |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/VcsRepositoryInfo.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/Version.java
// public class Version {
//
// private static final Properties PROPERTIES = load();
//
// public static final String VERSION = PROPERTIES.getProperty("version", "unknown");
// public static final String GROUP = PROPERTIES.getProperty("group", Version.class.getPackage().getName());
// public static final String NAME = PROPERTIES.getProperty("name", Version.class.getPackage().getName());
// public static final String DESCIPTION = PROPERTIES.getProperty("description", "");
//
// private static Properties load() {
// final Properties result = new Properties();
// final InputStream is = Version.class.getClassLoader().getResourceAsStream("org/echocat/gradle/plugins/golang/version.properties");
// if (is != null) {
// try (final Reader reader = new InputStreamReader(is, "UTF-8")) {
// result.load(reader);
// } catch (final IOException e) {
// throw new RuntimeException("Could not read version.properties.", e);
// } finally {
// closeQuietly(is);
// }
// }
// return result;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
| import com.google.gson.annotations.SerializedName;
import org.echocat.gradle.plugins.golang.Version;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import java.net.URI; | package org.echocat.gradle.plugins.golang.model;
public class VcsRepositoryInfo {
@SerializedName("creator")
private String _creator = Version.NAME + " " + Version.VERSION;
@SerializedName("type") | // Path: src/main/java/org/echocat/gradle/plugins/golang/Version.java
// public class Version {
//
// private static final Properties PROPERTIES = load();
//
// public static final String VERSION = PROPERTIES.getProperty("version", "unknown");
// public static final String GROUP = PROPERTIES.getProperty("group", Version.class.getPackage().getName());
// public static final String NAME = PROPERTIES.getProperty("name", Version.class.getPackage().getName());
// public static final String DESCIPTION = PROPERTIES.getProperty("description", "");
//
// private static Properties load() {
// final Properties result = new Properties();
// final InputStream is = Version.class.getClassLoader().getResourceAsStream("org/echocat/gradle/plugins/golang/version.properties");
// if (is != null) {
// try (final Reader reader = new InputStreamReader(is, "UTF-8")) {
// result.load(reader);
// } catch (final IOException e) {
// throw new RuntimeException("Could not read version.properties.", e);
// } finally {
// closeQuietly(is);
// }
// }
// return result;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/VcsRepositoryInfo.java
import com.google.gson.annotations.SerializedName;
import org.echocat.gradle.plugins.golang.Version;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import java.net.URI;
package org.echocat.gradle.plugins.golang.model;
public class VcsRepositoryInfo {
@SerializedName("creator")
private String _creator = Version.NAME + " " + Version.VERSION;
@SerializedName("type") | private VcsType _type; |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/DefaultVcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import javax.annotation.Nonnull;
import java.util.regex.Pattern; | package org.echocat.gradle.plugins.golang.vcs.isps;
public class DefaultVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/DefaultVcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import javax.annotation.Nonnull;
import java.util.regex.Pattern;
package org.echocat.gradle.plugins.golang.vcs.isps;
public class DefaultVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
@Nonnull | private final VcsType _type; |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/DefaultVcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import javax.annotation.Nonnull;
import java.util.regex.Pattern; | package org.echocat.gradle.plugins.golang.vcs.isps;
public class DefaultVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
@Nonnull
private final VcsType _type;
@Nonnull
private final String _name;
public DefaultVcsRepositoryProvider(@Nonnull VcsType type, @Nonnull String prefix, @Nonnull String name, @Nonnull Pattern dependencyPattern) {
super(prefix, dependencyPattern);
_type = type;
_name = name;
}
@Nonnull
@Override | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/DefaultVcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import javax.annotation.Nonnull;
import java.util.regex.Pattern;
package org.echocat.gradle.plugins.golang.vcs.isps;
public class DefaultVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
@Nonnull
private final VcsType _type;
@Nonnull
private final String _name;
public DefaultVcsRepositoryProvider(@Nonnull VcsType type, @Nonnull String prefix, @Nonnull String name, @Nonnull Pattern dependencyPattern) {
super(prefix, dependencyPattern);
_type = type;
_name = name;
}
@Nonnull
@Override | protected VcsType detectVcsTypeOf(@Nonnull RawVcsReference rawReference) throws VcsException { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/DefaultVcsRepositoryProvider.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
| import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import javax.annotation.Nonnull;
import java.util.regex.Pattern; | package org.echocat.gradle.plugins.golang.vcs.isps;
public class DefaultVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
@Nonnull
private final VcsType _type;
@Nonnull
private final String _name;
public DefaultVcsRepositoryProvider(@Nonnull VcsType type, @Nonnull String prefix, @Nonnull String name, @Nonnull Pattern dependencyPattern) {
super(prefix, dependencyPattern);
_type = type;
_name = name;
}
@Nonnull
@Override | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsException.java
// public class VcsException extends IOException {
//
// public VcsException(String message) {
// super(message);
// }
//
// public VcsException(String message, Throwable cause) {
// super(messageFor(message, cause), cause);
// }
//
// public VcsException(Throwable cause) {
// this(null, cause);
// }
//
// protected static String messageFor(String message, Throwable cause) {
// if (isNotEmpty(message)) {
// return message;
// }
// if (cause != null) {
// final String causeMessage = cause.getMessage();
// if (isNotEmpty(causeMessage)) {
// return causeMessage;
// }
// }
// return null;
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/isps/DefaultVcsRepositoryProvider.java
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsException;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import javax.annotation.Nonnull;
import java.util.regex.Pattern;
package org.echocat.gradle.plugins.golang.vcs.isps;
public class DefaultVcsRepositoryProvider extends IspBasedVcsRepositoryProviderSupport {
@Nonnull
private final VcsType _type;
@Nonnull
private final String _name;
public DefaultVcsRepositoryProvider(@Nonnull VcsType type, @Nonnull String prefix, @Nonnull String name, @Nonnull Pattern dependencyPattern) {
super(prefix, dependencyPattern);
_type = type;
_name = name;
}
@Nonnull
@Override | protected VcsType detectVcsTypeOf(@Nonnull RawVcsReference rawReference) throws VcsException { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
| import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.gradle.api.artifacts.Dependency;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import java.nio.file.Path;
import java.util.Objects;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.echocat.gradle.plugins.golang.model.GolangDependency.Type.explicit;
import static org.echocat.gradle.plugins.golang.model.UpdatePolicy.defaultUpdatePolicy; | package org.echocat.gradle.plugins.golang.model;
public class GolangDependency implements Dependency, Comparable<GolangDependency> {
@Nonnull
private String _group = "<unknown>";
@Nullable
private String _version;
@Nullable
private URI _repositoryUri;
@Nullable | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.gradle.api.artifacts.Dependency;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import java.nio.file.Path;
import java.util.Objects;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.echocat.gradle.plugins.golang.model.GolangDependency.Type.explicit;
import static org.echocat.gradle.plugins.golang.model.UpdatePolicy.defaultUpdatePolicy;
package org.echocat.gradle.plugins.golang.model;
public class GolangDependency implements Dependency, Comparable<GolangDependency> {
@Nonnull
private String _group = "<unknown>";
@Nullable
private String _version;
@Nullable
private URI _repositoryUri;
@Nullable | private VcsType _repositoryType; |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
| import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.gradle.api.artifacts.Dependency;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import java.nio.file.Path;
import java.util.Objects;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.echocat.gradle.plugins.golang.model.GolangDependency.Type.explicit;
import static org.echocat.gradle.plugins.golang.model.UpdatePolicy.defaultUpdatePolicy; | package org.echocat.gradle.plugins.golang.model;
public class GolangDependency implements Dependency, Comparable<GolangDependency> {
@Nonnull
private String _group = "<unknown>";
@Nullable
private String _version;
@Nullable
private URI _repositoryUri;
@Nullable
private VcsType _repositoryType;
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.gradle.api.artifacts.Dependency;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import java.nio.file.Path;
import java.util.Objects;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.echocat.gradle.plugins.golang.model.GolangDependency.Type.explicit;
import static org.echocat.gradle.plugins.golang.model.UpdatePolicy.defaultUpdatePolicy;
package org.echocat.gradle.plugins.golang.model;
public class GolangDependency implements Dependency, Comparable<GolangDependency> {
@Nonnull
private String _group = "<unknown>";
@Nullable
private String _version;
@Nullable
private URI _repositoryUri;
@Nullable
private VcsType _repositoryType;
@Nonnull | private UpdatePolicy _updatePolicy = defaultUpdatePolicy(); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
| import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.gradle.api.artifacts.Dependency;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import java.nio.file.Path;
import java.util.Objects;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.echocat.gradle.plugins.golang.model.GolangDependency.Type.explicit;
import static org.echocat.gradle.plugins.golang.model.UpdatePolicy.defaultUpdatePolicy; | }
protected <T extends Comparable<T>> int compare(@Nullable T a, @Nullable T b) {
if (a == null && b == null) {
return 0;
}
if (a == null) {
return 1;
}
if (b == null) {
return -1;
}
return a.compareTo(b);
}
@Override
public GolangDependency copy() {
return new GolangDependency()
.setGroup(getGroup())
.setVersion(getVersion())
.setRepositoryUri(getRepositoryUri())
.setRepositoryType(getRepositoryType())
.setUpdatePolicy(getUpdatePolicy())
.setLocation(getLocation())
.setParent(getParent())
.setType(getType())
;
}
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.gradle.api.artifacts.Dependency;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import java.nio.file.Path;
import java.util.Objects;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.echocat.gradle.plugins.golang.model.GolangDependency.Type.explicit;
import static org.echocat.gradle.plugins.golang.model.UpdatePolicy.defaultUpdatePolicy;
}
protected <T extends Comparable<T>> int compare(@Nullable T a, @Nullable T b) {
if (a == null && b == null) {
return 0;
}
if (a == null) {
return 1;
}
if (b == null) {
return -1;
}
return a.compareTo(b);
}
@Override
public GolangDependency copy() {
return new GolangDependency()
.setGroup(getGroup())
.setVersion(getVersion())
.setRepositoryUri(getRepositoryUri())
.setRepositoryType(getRepositoryType())
.setUpdatePolicy(getUpdatePolicy())
.setLocation(getLocation())
.setParent(getParent())
.setType(getType())
;
}
@Nonnull | public RawVcsReference toRawVcsReference() throws VcsValidationException { |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
| import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.gradle.api.artifacts.Dependency;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import java.nio.file.Path;
import java.util.Objects;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.echocat.gradle.plugins.golang.model.GolangDependency.Type.explicit;
import static org.echocat.gradle.plugins.golang.model.UpdatePolicy.defaultUpdatePolicy; | }
protected <T extends Comparable<T>> int compare(@Nullable T a, @Nullable T b) {
if (a == null && b == null) {
return 0;
}
if (a == null) {
return 1;
}
if (b == null) {
return -1;
}
return a.compareTo(b);
}
@Override
public GolangDependency copy() {
return new GolangDependency()
.setGroup(getGroup())
.setVersion(getVersion())
.setRepositoryUri(getRepositoryUri())
.setRepositoryType(getRepositoryType())
.setUpdatePolicy(getUpdatePolicy())
.setLocation(getLocation())
.setParent(getParent())
.setType(getType())
;
}
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/RawVcsReference.java
// public class RawVcsReference extends BaseVcsReference {
//
// public RawVcsReference(@Nullable VcsType type, @Nonnull String id, @Nullable URI plain, @Nullable String ref, UpdatePolicy updatePolicy) {
// super(type, id, plain, ref, updatePolicy);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsType.java
// public enum VcsType {
// git(".git"),
// bzr(".bzr"),
// hg(".hg"),
// svn(".svn"),
// manual("");
//
// @Nonnull
// private final String _uriSuffix;
// @Nonnull
// private final Set<String> _schemes;
//
// VcsType(@Nonnull String uriSuffix, @Nullable String... plainSchemes) {
// _uriSuffix = uriSuffix;
// final Set<String> schemes = new LinkedHashSet<>();
// if (plainSchemes != null) {
// addAll(schemes, plainSchemes);
// }
// _schemes = unmodifiableSet(schemes);
// }
//
// @Nonnull
// public String getUriSuffix() {
// return _uriSuffix;
// }
//
// @Nonnull
// public Set<String> getSchemes() {
// return _schemes;
// }
//
// @Nonnull
// public String getName() {
// return name();
// }
//
// @Override
// public String toString() {
// return getName();
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/UpdatePolicy.java
// @Nonnull
// public static UpdatePolicy defaultUpdatePolicy() {
// return never();
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/model/GolangDependency.java
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.echocat.gradle.plugins.golang.vcs.RawVcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsType;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.gradle.api.artifacts.Dependency;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.net.URI;
import java.nio.file.Path;
import java.util.Objects;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.echocat.gradle.plugins.golang.model.GolangDependency.Type.explicit;
import static org.echocat.gradle.plugins.golang.model.UpdatePolicy.defaultUpdatePolicy;
}
protected <T extends Comparable<T>> int compare(@Nullable T a, @Nullable T b) {
if (a == null && b == null) {
return 0;
}
if (a == null) {
return 1;
}
if (b == null) {
return -1;
}
return a.compareTo(b);
}
@Override
public GolangDependency copy() {
return new GolangDependency()
.setGroup(getGroup())
.setVersion(getVersion())
.setRepositoryUri(getRepositoryUri())
.setRepositoryType(getRepositoryType())
.setUpdatePolicy(getUpdatePolicy())
.setLocation(getLocation())
.setParent(getParent())
.setType(getType())
;
}
@Nonnull | public RawVcsReference toRawVcsReference() throws VcsValidationException { |
echocat/gradle-golang-plugin | src/test/java/org/echocat/gradle/plugins/golang/vcs/git/GitVcsRepositoryExternalTest.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public class VcsReference extends BaseVcsReference {
//
// @Nullable
// private final String _subPath;
//
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull String plain, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// super(type, id, URI.create(plain), ref, defaultUpdatePolicy());
// //noinspection ConstantConditions
// if (type == null) {
// throw new VcsValidationException("Empty type provided.");
// }
// if (isEmpty(plain)) {
// throw new VcsValidationException("Empty uri provided.");
// }
// _subPath = subPath;
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull URI uri, @Nullable String ref, @Nonnull UpdatePolicy updatePolicy, @Nullable String subPath) {
// super(type, id, uri, ref, updatePolicy);
// //noinspection ConstantConditions
// if (type == null) {
// throw new NullPointerException("type is null");
// }
// //noinspection ConstantConditions
// if (uri == null) {
// throw new NullPointerException("uri is null");
// }
// _subPath = subPath;
// }
//
// @Nonnull
// @Override
// public VcsType getType() {
// //noinspection ConstantConditions
// return super.getType();
// }
//
// @Override
// @Nonnull
// public URI getUri() {
// //noinspection ConstantConditions
// return super.getUri();
// }
//
// @Nullable
// public String getSubPath() {
// return _subPath;
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
| import org.echocat.gradle.plugins.golang.vcs.VcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.junit.Test;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.nio.file.Paths;
import static org.echocat.gradle.plugins.golang.vcs.VcsReference.vcsReference;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat; | package org.echocat.gradle.plugins.golang.vcs.git;
public class GitVcsRepositoryExternalTest {
private static final String NAME = "github.com/echocat/caretakerd";
private static final String URI = "https://github.com/echocat/caretakerd.git";
@SuppressWarnings("ConstantConditions")
@Test
public void test() throws Exception {
new GitVcsRepository(referenceFor("refs/tags/v0.1.12")).updateIfRequired(Paths.get("build/test/123"));
assertThat(new GitVcsRepository(referenceFor(null)).resolveRemoteRef().getName(), equalTo("HEAD"));
assertThat(new GitVcsRepository(referenceFor("master")).resolveRemoteRef().getName(), equalTo("refs/heads/master"));
assertThat(new GitVcsRepository(referenceFor("refs/master")).resolveRemoteRef(), nullValue());
assertThat(new GitVcsRepository(referenceFor("refs/heads/master")).resolveRemoteRef().getName(), equalTo("refs/heads/master"));
assertThat(new GitVcsRepository(referenceFor("v0.1.12")).resolveRemoteRef().getName(), equalTo("refs/tags/v0.1.12"));
assertThat(new GitVcsRepository(referenceFor("refs/v0.1.12")).resolveRemoteRef(), nullValue());
assertThat(new GitVcsRepository(referenceFor("refs/tags/v0.1.12")).resolveRemoteRef().getName(), equalTo("refs/tags/v0.1.12"));
}
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public class VcsReference extends BaseVcsReference {
//
// @Nullable
// private final String _subPath;
//
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull String plain, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// super(type, id, URI.create(plain), ref, defaultUpdatePolicy());
// //noinspection ConstantConditions
// if (type == null) {
// throw new VcsValidationException("Empty type provided.");
// }
// if (isEmpty(plain)) {
// throw new VcsValidationException("Empty uri provided.");
// }
// _subPath = subPath;
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull URI uri, @Nullable String ref, @Nonnull UpdatePolicy updatePolicy, @Nullable String subPath) {
// super(type, id, uri, ref, updatePolicy);
// //noinspection ConstantConditions
// if (type == null) {
// throw new NullPointerException("type is null");
// }
// //noinspection ConstantConditions
// if (uri == null) {
// throw new NullPointerException("uri is null");
// }
// _subPath = subPath;
// }
//
// @Nonnull
// @Override
// public VcsType getType() {
// //noinspection ConstantConditions
// return super.getType();
// }
//
// @Override
// @Nonnull
// public URI getUri() {
// //noinspection ConstantConditions
// return super.getUri();
// }
//
// @Nullable
// public String getSubPath() {
// return _subPath;
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
// Path: src/test/java/org/echocat/gradle/plugins/golang/vcs/git/GitVcsRepositoryExternalTest.java
import org.echocat.gradle.plugins.golang.vcs.VcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.junit.Test;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.nio.file.Paths;
import static org.echocat.gradle.plugins.golang.vcs.VcsReference.vcsReference;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
package org.echocat.gradle.plugins.golang.vcs.git;
public class GitVcsRepositoryExternalTest {
private static final String NAME = "github.com/echocat/caretakerd";
private static final String URI = "https://github.com/echocat/caretakerd.git";
@SuppressWarnings("ConstantConditions")
@Test
public void test() throws Exception {
new GitVcsRepository(referenceFor("refs/tags/v0.1.12")).updateIfRequired(Paths.get("build/test/123"));
assertThat(new GitVcsRepository(referenceFor(null)).resolveRemoteRef().getName(), equalTo("HEAD"));
assertThat(new GitVcsRepository(referenceFor("master")).resolveRemoteRef().getName(), equalTo("refs/heads/master"));
assertThat(new GitVcsRepository(referenceFor("refs/master")).resolveRemoteRef(), nullValue());
assertThat(new GitVcsRepository(referenceFor("refs/heads/master")).resolveRemoteRef().getName(), equalTo("refs/heads/master"));
assertThat(new GitVcsRepository(referenceFor("v0.1.12")).resolveRemoteRef().getName(), equalTo("refs/tags/v0.1.12"));
assertThat(new GitVcsRepository(referenceFor("refs/v0.1.12")).resolveRemoteRef(), nullValue());
assertThat(new GitVcsRepository(referenceFor("refs/tags/v0.1.12")).resolveRemoteRef().getName(), equalTo("refs/tags/v0.1.12"));
}
@Nonnull | protected VcsReference referenceFor(@Nullable String ref) throws VcsValidationException { |
echocat/gradle-golang-plugin | src/test/java/org/echocat/gradle/plugins/golang/vcs/git/GitVcsRepositoryExternalTest.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public class VcsReference extends BaseVcsReference {
//
// @Nullable
// private final String _subPath;
//
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull String plain, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// super(type, id, URI.create(plain), ref, defaultUpdatePolicy());
// //noinspection ConstantConditions
// if (type == null) {
// throw new VcsValidationException("Empty type provided.");
// }
// if (isEmpty(plain)) {
// throw new VcsValidationException("Empty uri provided.");
// }
// _subPath = subPath;
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull URI uri, @Nullable String ref, @Nonnull UpdatePolicy updatePolicy, @Nullable String subPath) {
// super(type, id, uri, ref, updatePolicy);
// //noinspection ConstantConditions
// if (type == null) {
// throw new NullPointerException("type is null");
// }
// //noinspection ConstantConditions
// if (uri == null) {
// throw new NullPointerException("uri is null");
// }
// _subPath = subPath;
// }
//
// @Nonnull
// @Override
// public VcsType getType() {
// //noinspection ConstantConditions
// return super.getType();
// }
//
// @Override
// @Nonnull
// public URI getUri() {
// //noinspection ConstantConditions
// return super.getUri();
// }
//
// @Nullable
// public String getSubPath() {
// return _subPath;
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
| import org.echocat.gradle.plugins.golang.vcs.VcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.junit.Test;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.nio.file.Paths;
import static org.echocat.gradle.plugins.golang.vcs.VcsReference.vcsReference;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat; | package org.echocat.gradle.plugins.golang.vcs.git;
public class GitVcsRepositoryExternalTest {
private static final String NAME = "github.com/echocat/caretakerd";
private static final String URI = "https://github.com/echocat/caretakerd.git";
@SuppressWarnings("ConstantConditions")
@Test
public void test() throws Exception {
new GitVcsRepository(referenceFor("refs/tags/v0.1.12")).updateIfRequired(Paths.get("build/test/123"));
assertThat(new GitVcsRepository(referenceFor(null)).resolveRemoteRef().getName(), equalTo("HEAD"));
assertThat(new GitVcsRepository(referenceFor("master")).resolveRemoteRef().getName(), equalTo("refs/heads/master"));
assertThat(new GitVcsRepository(referenceFor("refs/master")).resolveRemoteRef(), nullValue());
assertThat(new GitVcsRepository(referenceFor("refs/heads/master")).resolveRemoteRef().getName(), equalTo("refs/heads/master"));
assertThat(new GitVcsRepository(referenceFor("v0.1.12")).resolveRemoteRef().getName(), equalTo("refs/tags/v0.1.12"));
assertThat(new GitVcsRepository(referenceFor("refs/v0.1.12")).resolveRemoteRef(), nullValue());
assertThat(new GitVcsRepository(referenceFor("refs/tags/v0.1.12")).resolveRemoteRef().getName(), equalTo("refs/tags/v0.1.12"));
}
@Nonnull | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public class VcsReference extends BaseVcsReference {
//
// @Nullable
// private final String _subPath;
//
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull String plain, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// super(type, id, URI.create(plain), ref, defaultUpdatePolicy());
// //noinspection ConstantConditions
// if (type == null) {
// throw new VcsValidationException("Empty type provided.");
// }
// if (isEmpty(plain)) {
// throw new VcsValidationException("Empty uri provided.");
// }
// _subPath = subPath;
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull URI uri, @Nullable String ref, @Nonnull UpdatePolicy updatePolicy, @Nullable String subPath) {
// super(type, id, uri, ref, updatePolicy);
// //noinspection ConstantConditions
// if (type == null) {
// throw new NullPointerException("type is null");
// }
// //noinspection ConstantConditions
// if (uri == null) {
// throw new NullPointerException("uri is null");
// }
// _subPath = subPath;
// }
//
// @Nonnull
// @Override
// public VcsType getType() {
// //noinspection ConstantConditions
// return super.getType();
// }
//
// @Override
// @Nonnull
// public URI getUri() {
// //noinspection ConstantConditions
// return super.getUri();
// }
//
// @Nullable
// public String getSubPath() {
// return _subPath;
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
// Path: src/test/java/org/echocat/gradle/plugins/golang/vcs/git/GitVcsRepositoryExternalTest.java
import org.echocat.gradle.plugins.golang.vcs.VcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.junit.Test;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.nio.file.Paths;
import static org.echocat.gradle.plugins.golang.vcs.VcsReference.vcsReference;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
package org.echocat.gradle.plugins.golang.vcs.git;
public class GitVcsRepositoryExternalTest {
private static final String NAME = "github.com/echocat/caretakerd";
private static final String URI = "https://github.com/echocat/caretakerd.git";
@SuppressWarnings("ConstantConditions")
@Test
public void test() throws Exception {
new GitVcsRepository(referenceFor("refs/tags/v0.1.12")).updateIfRequired(Paths.get("build/test/123"));
assertThat(new GitVcsRepository(referenceFor(null)).resolveRemoteRef().getName(), equalTo("HEAD"));
assertThat(new GitVcsRepository(referenceFor("master")).resolveRemoteRef().getName(), equalTo("refs/heads/master"));
assertThat(new GitVcsRepository(referenceFor("refs/master")).resolveRemoteRef(), nullValue());
assertThat(new GitVcsRepository(referenceFor("refs/heads/master")).resolveRemoteRef().getName(), equalTo("refs/heads/master"));
assertThat(new GitVcsRepository(referenceFor("v0.1.12")).resolveRemoteRef().getName(), equalTo("refs/tags/v0.1.12"));
assertThat(new GitVcsRepository(referenceFor("refs/v0.1.12")).resolveRemoteRef(), nullValue());
assertThat(new GitVcsRepository(referenceFor("refs/tags/v0.1.12")).resolveRemoteRef().getName(), equalTo("refs/tags/v0.1.12"));
}
@Nonnull | protected VcsReference referenceFor(@Nullable String ref) throws VcsValidationException { |
echocat/gradle-golang-plugin | src/test/java/org/echocat/gradle/plugins/golang/vcs/git/GitVcsRepositoryExternalTest.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public class VcsReference extends BaseVcsReference {
//
// @Nullable
// private final String _subPath;
//
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull String plain, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// super(type, id, URI.create(plain), ref, defaultUpdatePolicy());
// //noinspection ConstantConditions
// if (type == null) {
// throw new VcsValidationException("Empty type provided.");
// }
// if (isEmpty(plain)) {
// throw new VcsValidationException("Empty uri provided.");
// }
// _subPath = subPath;
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull URI uri, @Nullable String ref, @Nonnull UpdatePolicy updatePolicy, @Nullable String subPath) {
// super(type, id, uri, ref, updatePolicy);
// //noinspection ConstantConditions
// if (type == null) {
// throw new NullPointerException("type is null");
// }
// //noinspection ConstantConditions
// if (uri == null) {
// throw new NullPointerException("uri is null");
// }
// _subPath = subPath;
// }
//
// @Nonnull
// @Override
// public VcsType getType() {
// //noinspection ConstantConditions
// return super.getType();
// }
//
// @Override
// @Nonnull
// public URI getUri() {
// //noinspection ConstantConditions
// return super.getUri();
// }
//
// @Nullable
// public String getSubPath() {
// return _subPath;
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
| import org.echocat.gradle.plugins.golang.vcs.VcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.junit.Test;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.nio.file.Paths;
import static org.echocat.gradle.plugins.golang.vcs.VcsReference.vcsReference;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat; | package org.echocat.gradle.plugins.golang.vcs.git;
public class GitVcsRepositoryExternalTest {
private static final String NAME = "github.com/echocat/caretakerd";
private static final String URI = "https://github.com/echocat/caretakerd.git";
@SuppressWarnings("ConstantConditions")
@Test
public void test() throws Exception {
new GitVcsRepository(referenceFor("refs/tags/v0.1.12")).updateIfRequired(Paths.get("build/test/123"));
assertThat(new GitVcsRepository(referenceFor(null)).resolveRemoteRef().getName(), equalTo("HEAD"));
assertThat(new GitVcsRepository(referenceFor("master")).resolveRemoteRef().getName(), equalTo("refs/heads/master"));
assertThat(new GitVcsRepository(referenceFor("refs/master")).resolveRemoteRef(), nullValue());
assertThat(new GitVcsRepository(referenceFor("refs/heads/master")).resolveRemoteRef().getName(), equalTo("refs/heads/master"));
assertThat(new GitVcsRepository(referenceFor("v0.1.12")).resolveRemoteRef().getName(), equalTo("refs/tags/v0.1.12"));
assertThat(new GitVcsRepository(referenceFor("refs/v0.1.12")).resolveRemoteRef(), nullValue());
assertThat(new GitVcsRepository(referenceFor("refs/tags/v0.1.12")).resolveRemoteRef().getName(), equalTo("refs/tags/v0.1.12"));
}
@Nonnull
protected VcsReference referenceFor(@Nullable String ref) throws VcsValidationException { | // Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public class VcsReference extends BaseVcsReference {
//
// @Nullable
// private final String _subPath;
//
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull String plain, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// super(type, id, URI.create(plain), ref, defaultUpdatePolicy());
// //noinspection ConstantConditions
// if (type == null) {
// throw new VcsValidationException("Empty type provided.");
// }
// if (isEmpty(plain)) {
// throw new VcsValidationException("Empty uri provided.");
// }
// _subPath = subPath;
// }
//
// public VcsReference(@Nonnull VcsType type, @Nonnull String id, @Nonnull URI uri, @Nullable String ref, @Nonnull UpdatePolicy updatePolicy, @Nullable String subPath) {
// super(type, id, uri, ref, updatePolicy);
// //noinspection ConstantConditions
// if (type == null) {
// throw new NullPointerException("type is null");
// }
// //noinspection ConstantConditions
// if (uri == null) {
// throw new NullPointerException("uri is null");
// }
// _subPath = subPath;
// }
//
// @Nonnull
// @Override
// public VcsType getType() {
// //noinspection ConstantConditions
// return super.getType();
// }
//
// @Override
// @Nonnull
// public URI getUri() {
// //noinspection ConstantConditions
// return super.getUri();
// }
//
// @Nullable
// public String getSubPath() {
// return _subPath;
// }
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsValidationException.java
// public class VcsValidationException extends VcsException {
//
// public VcsValidationException(String message) {
// super(message);
// }
//
// public VcsValidationException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public VcsValidationException(Throwable cause) {
// super(cause);
// }
//
// }
//
// Path: src/main/java/org/echocat/gradle/plugins/golang/vcs/VcsReference.java
// public static VcsReference vcsReference(@Nonnull VcsType type, @Nonnull String name, @Nonnull String plainUri, @Nullable String ref, @Nullable String subPath) throws VcsValidationException {
// return new VcsReference(type, name, plainUri, ref, subPath);
// }
// Path: src/test/java/org/echocat/gradle/plugins/golang/vcs/git/GitVcsRepositoryExternalTest.java
import org.echocat.gradle.plugins.golang.vcs.VcsReference;
import org.echocat.gradle.plugins.golang.vcs.VcsValidationException;
import org.junit.Test;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.nio.file.Paths;
import static org.echocat.gradle.plugins.golang.vcs.VcsReference.vcsReference;
import static org.echocat.gradle.plugins.golang.vcs.VcsType.git;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;
package org.echocat.gradle.plugins.golang.vcs.git;
public class GitVcsRepositoryExternalTest {
private static final String NAME = "github.com/echocat/caretakerd";
private static final String URI = "https://github.com/echocat/caretakerd.git";
@SuppressWarnings("ConstantConditions")
@Test
public void test() throws Exception {
new GitVcsRepository(referenceFor("refs/tags/v0.1.12")).updateIfRequired(Paths.get("build/test/123"));
assertThat(new GitVcsRepository(referenceFor(null)).resolveRemoteRef().getName(), equalTo("HEAD"));
assertThat(new GitVcsRepository(referenceFor("master")).resolveRemoteRef().getName(), equalTo("refs/heads/master"));
assertThat(new GitVcsRepository(referenceFor("refs/master")).resolveRemoteRef(), nullValue());
assertThat(new GitVcsRepository(referenceFor("refs/heads/master")).resolveRemoteRef().getName(), equalTo("refs/heads/master"));
assertThat(new GitVcsRepository(referenceFor("v0.1.12")).resolveRemoteRef().getName(), equalTo("refs/tags/v0.1.12"));
assertThat(new GitVcsRepository(referenceFor("refs/v0.1.12")).resolveRemoteRef(), nullValue());
assertThat(new GitVcsRepository(referenceFor("refs/tags/v0.1.12")).resolveRemoteRef().getName(), equalTo("refs/tags/v0.1.12"));
}
@Nonnull
protected VcsReference referenceFor(@Nullable String ref) throws VcsValidationException { | return vcsReference(git, NAME, URI, ref, null); |
echocat/gradle-golang-plugin | src/main/java/org/echocat/gradle/plugins/golang/utils/IOUtils.java | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/StdStreams.java
// public static class Impl implements StdStreams {
//
// @Nonnull
// public static StdStreams stdStreams(@Nonnull OutputStream out, @Nonnull OutputStream err) {
// return new Impl(out, err);
// }
//
// @Nonnull
// public static StdStreams stdStreams(@Nonnull OutputStream out) {
// return stdStreams(out, out);
// }
//
// @Nonnull
// private final OutputStream _out;
// @Nonnull
// private final OutputStream _err;
//
// public Impl(@Nonnull OutputStream out, @Nonnull OutputStream err) {
// _out = out;
// _err = err;
// }
//
// @Override
// @Nonnull
// public OutputStream out() {
// return _out;
// }
//
// @Override
// @Nonnull
// public OutputStream err() {
// return _err;
// }
//
// @Override
// public void close() throws IOException {
// closeQuietly(_out);
// closeQuietly(_err);
// }
//
// }
| import org.apache.commons.io.output.TeeOutputStream;
import org.echocat.gradle.plugins.golang.utils.StdStreams.Impl;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.OutputStream; | package org.echocat.gradle.plugins.golang.utils;
public final class IOUtils {
@Nonnull
public static StdStreams tee(@Nonnull StdStreams a, @Nonnull StdStreams b) {
final OutputStream out = new TeeOutputStream(a.out(), b.out());
final OutputStream err = new TeeOutputStream(a.err(), b.err()); | // Path: src/main/java/org/echocat/gradle/plugins/golang/utils/StdStreams.java
// public static class Impl implements StdStreams {
//
// @Nonnull
// public static StdStreams stdStreams(@Nonnull OutputStream out, @Nonnull OutputStream err) {
// return new Impl(out, err);
// }
//
// @Nonnull
// public static StdStreams stdStreams(@Nonnull OutputStream out) {
// return stdStreams(out, out);
// }
//
// @Nonnull
// private final OutputStream _out;
// @Nonnull
// private final OutputStream _err;
//
// public Impl(@Nonnull OutputStream out, @Nonnull OutputStream err) {
// _out = out;
// _err = err;
// }
//
// @Override
// @Nonnull
// public OutputStream out() {
// return _out;
// }
//
// @Override
// @Nonnull
// public OutputStream err() {
// return _err;
// }
//
// @Override
// public void close() throws IOException {
// closeQuietly(_out);
// closeQuietly(_err);
// }
//
// }
// Path: src/main/java/org/echocat/gradle/plugins/golang/utils/IOUtils.java
import org.apache.commons.io.output.TeeOutputStream;
import org.echocat.gradle.plugins.golang.utils.StdStreams.Impl;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.OutputStream;
package org.echocat.gradle.plugins.golang.utils;
public final class IOUtils {
@Nonnull
public static StdStreams tee(@Nonnull StdStreams a, @Nonnull StdStreams b) {
final OutputStream out = new TeeOutputStream(a.out(), b.out());
final OutputStream err = new TeeOutputStream(a.err(), b.err()); | return new Impl(out, err); |
futurice/vor | vor-android/mobile/src/main/java/com/futurice/vor/fragment/Floor7Fragment.java | // Path: vor-android/mobile/src/main/java/com/futurice/vor/utils/ToiletUtils.java
// public class ToiletUtils {
// /**
// * Implementation of the click listener to show methane level
// *
// * @param json the json string
// */
// public static void setClickListener(String json, Context context) {
// if (json != null) {
// try {
// JSONObject jsonData = new JSONObject(json);
// Integer methane = jsonData.getInt(METHANE_KEY);
// showMethaneToast(methane, context);
// } catch (JSONException e) {
// e.printStackTrace();
// }
// }
// }
//
// public static void updateView(SharedPreferences sharedPreferences, String key, View view, Context context) {
// String json = sharedPreferences.getString(key, null);
// if (json != null) {
// try {
// JSONObject jsonData = new JSONObject(json);
// updateToiletBackground(view, jsonData.getBoolean(RESERVED_KEY), context);
// } catch (JSONException e) {
// e.printStackTrace();
// }
// }
// }
//
// /**
// * Updates the background of the view depending on toilet availability
// *
// * @param view the view
// * @param reserved the state of the toilet
// */
// public static void updateToiletBackground(View view, Boolean reserved, Context context) {
// Drawable freeBg = ContextCompat.getDrawable(context, R.drawable.toilet_free_bg);
// Drawable takenBg = ContextCompat.getDrawable(context, R.drawable.toilet_taken_bg);
// view.setBackground(reserved ? takenBg : freeBg);
// }
//
// /**
// * Shows a toast with the methane level
// *
// * @param methane the methane level
// *
// * @param context the context
// */
// public static void showMethaneToast(Integer methane, Context context) {
// String message = "Methane level: " + Integer.toString(methane);
// Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
// }
// }
| import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import com.futurice.vor.R;
import com.futurice.vor.Toilet;
import com.futurice.vor.utils.ToiletUtils;
import butterknife.Bind;
import butterknife.ButterKnife; | package com.futurice.vor.fragment;
public class Floor7Fragment extends Fragment {
@Bind(R.id.toilet7AM) RelativeLayout mToilet7AM;
@Bind(R.id.toilet7BM) RelativeLayout mToilet7BM;
Activity mActivity;
SharedPreferences mToilet7amSP;
SharedPreferences mToilet7bmSP;
OnSharedPreferenceChangeListener toilet7amListener = (sharedPreferences, key) -> { | // Path: vor-android/mobile/src/main/java/com/futurice/vor/utils/ToiletUtils.java
// public class ToiletUtils {
// /**
// * Implementation of the click listener to show methane level
// *
// * @param json the json string
// */
// public static void setClickListener(String json, Context context) {
// if (json != null) {
// try {
// JSONObject jsonData = new JSONObject(json);
// Integer methane = jsonData.getInt(METHANE_KEY);
// showMethaneToast(methane, context);
// } catch (JSONException e) {
// e.printStackTrace();
// }
// }
// }
//
// public static void updateView(SharedPreferences sharedPreferences, String key, View view, Context context) {
// String json = sharedPreferences.getString(key, null);
// if (json != null) {
// try {
// JSONObject jsonData = new JSONObject(json);
// updateToiletBackground(view, jsonData.getBoolean(RESERVED_KEY), context);
// } catch (JSONException e) {
// e.printStackTrace();
// }
// }
// }
//
// /**
// * Updates the background of the view depending on toilet availability
// *
// * @param view the view
// * @param reserved the state of the toilet
// */
// public static void updateToiletBackground(View view, Boolean reserved, Context context) {
// Drawable freeBg = ContextCompat.getDrawable(context, R.drawable.toilet_free_bg);
// Drawable takenBg = ContextCompat.getDrawable(context, R.drawable.toilet_taken_bg);
// view.setBackground(reserved ? takenBg : freeBg);
// }
//
// /**
// * Shows a toast with the methane level
// *
// * @param methane the methane level
// *
// * @param context the context
// */
// public static void showMethaneToast(Integer methane, Context context) {
// String message = "Methane level: " + Integer.toString(methane);
// Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
// }
// }
// Path: vor-android/mobile/src/main/java/com/futurice/vor/fragment/Floor7Fragment.java
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import com.futurice.vor.R;
import com.futurice.vor.Toilet;
import com.futurice.vor.utils.ToiletUtils;
import butterknife.Bind;
import butterknife.ButterKnife;
package com.futurice.vor.fragment;
public class Floor7Fragment extends Fragment {
@Bind(R.id.toilet7AM) RelativeLayout mToilet7AM;
@Bind(R.id.toilet7BM) RelativeLayout mToilet7BM;
Activity mActivity;
SharedPreferences mToilet7amSP;
SharedPreferences mToilet7bmSP;
OnSharedPreferenceChangeListener toilet7amListener = (sharedPreferences, key) -> { | ToiletUtils.updateView(sharedPreferences, key, mToilet7AM, getActivity()); |
futurice/vor | vor-android/mobile/src/main/java/com/futurice/vor/activity/SpaceActivity.java | // Path: vor-android/mobile/src/main/java/com/futurice/vor/view/CustomViewPager.java
// public class CustomViewPager extends ViewPager {
//
// public CustomViewPager(Context context) {
// super(context);
// }
//
// public CustomViewPager(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// /*
// * There is a problem with PhotoView's behavior with ViewPager.
// * This override prevents the app from crashing.
// * https://github.com/chrisbanes/PhotoView/issues/72
// */
// @Override
// public boolean onInterceptTouchEvent(MotionEvent ev) {
// try {
// return super.onInterceptTouchEvent(ev);
// } catch (Exception e) {
// e.printStackTrace();
// return false;
// }
// }
// }
| import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.futurice.vor.R;
import com.futurice.vor.view.CustomViewPager; | package com.futurice.vor.activity;
public class SpaceActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_space);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
| // Path: vor-android/mobile/src/main/java/com/futurice/vor/view/CustomViewPager.java
// public class CustomViewPager extends ViewPager {
//
// public CustomViewPager(Context context) {
// super(context);
// }
//
// public CustomViewPager(Context context, AttributeSet attrs) {
// super(context, attrs);
// }
//
// /*
// * There is a problem with PhotoView's behavior with ViewPager.
// * This override prevents the app from crashing.
// * https://github.com/chrisbanes/PhotoView/issues/72
// */
// @Override
// public boolean onInterceptTouchEvent(MotionEvent ev) {
// try {
// return super.onInterceptTouchEvent(ev);
// } catch (Exception e) {
// e.printStackTrace();
// return false;
// }
// }
// }
// Path: vor-android/mobile/src/main/java/com/futurice/vor/activity/SpaceActivity.java
import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.futurice.vor.R;
import com.futurice.vor.view.CustomViewPager;
package com.futurice.vor.activity;
public class SpaceActivity extends BaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_space);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
| CustomViewPager viewPager = (CustomViewPager) findViewById(R.id.container); |
futurice/vor | vor-android/mobile/src/main/java/com/futurice/vor/fragment/Floor8Fragment.java | // Path: vor-android/mobile/src/main/java/com/futurice/vor/utils/ToiletUtils.java
// public class ToiletUtils {
// /**
// * Implementation of the click listener to show methane level
// *
// * @param json the json string
// */
// public static void setClickListener(String json, Context context) {
// if (json != null) {
// try {
// JSONObject jsonData = new JSONObject(json);
// Integer methane = jsonData.getInt(METHANE_KEY);
// showMethaneToast(methane, context);
// } catch (JSONException e) {
// e.printStackTrace();
// }
// }
// }
//
// public static void updateView(SharedPreferences sharedPreferences, String key, View view, Context context) {
// String json = sharedPreferences.getString(key, null);
// if (json != null) {
// try {
// JSONObject jsonData = new JSONObject(json);
// updateToiletBackground(view, jsonData.getBoolean(RESERVED_KEY), context);
// } catch (JSONException e) {
// e.printStackTrace();
// }
// }
// }
//
// /**
// * Updates the background of the view depending on toilet availability
// *
// * @param view the view
// * @param reserved the state of the toilet
// */
// public static void updateToiletBackground(View view, Boolean reserved, Context context) {
// Drawable freeBg = ContextCompat.getDrawable(context, R.drawable.toilet_free_bg);
// Drawable takenBg = ContextCompat.getDrawable(context, R.drawable.toilet_taken_bg);
// view.setBackground(reserved ? takenBg : freeBg);
// }
//
// /**
// * Shows a toast with the methane level
// *
// * @param methane the methane level
// *
// * @param context the context
// */
// public static void showMethaneToast(Integer methane, Context context) {
// String message = "Methane level: " + Integer.toString(methane);
// Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
// }
// }
| import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import com.futurice.vor.R;
import com.futurice.vor.Toilet;
import com.futurice.vor.utils.ToiletUtils;
import java.util.ArrayList;
import butterknife.Bind;
import butterknife.ButterKnife; | mIds.add(Toilet.CM8.getId());
mIds.add(Toilet.CW8.getId());
for (String id : mIds) {
mSharedPreferences.add(mActivity.getSharedPreferences(id, Context.MODE_PRIVATE));
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_floor_8_toilet, container, false);
ButterKnife.bind(this, view);
setupView();
return view;
}
private void setupView() {
mRelativeLayouts.add(mToilet8AM);
mRelativeLayouts.add(mToilet8AW);
mRelativeLayouts.add(mToilet8BM);
mRelativeLayouts.add(mToilet8BW);
mRelativeLayouts.add(mToilet8CM);
mRelativeLayouts.add(mToilet8CW);
for (int i = 0; i < mRelativeLayouts.size(); i++) {
RelativeLayout relativeLayout = mRelativeLayouts.get(i);
mOnSharedPreferenceChangeListeners.add((sharedPreferences, key) -> { | // Path: vor-android/mobile/src/main/java/com/futurice/vor/utils/ToiletUtils.java
// public class ToiletUtils {
// /**
// * Implementation of the click listener to show methane level
// *
// * @param json the json string
// */
// public static void setClickListener(String json, Context context) {
// if (json != null) {
// try {
// JSONObject jsonData = new JSONObject(json);
// Integer methane = jsonData.getInt(METHANE_KEY);
// showMethaneToast(methane, context);
// } catch (JSONException e) {
// e.printStackTrace();
// }
// }
// }
//
// public static void updateView(SharedPreferences sharedPreferences, String key, View view, Context context) {
// String json = sharedPreferences.getString(key, null);
// if (json != null) {
// try {
// JSONObject jsonData = new JSONObject(json);
// updateToiletBackground(view, jsonData.getBoolean(RESERVED_KEY), context);
// } catch (JSONException e) {
// e.printStackTrace();
// }
// }
// }
//
// /**
// * Updates the background of the view depending on toilet availability
// *
// * @param view the view
// * @param reserved the state of the toilet
// */
// public static void updateToiletBackground(View view, Boolean reserved, Context context) {
// Drawable freeBg = ContextCompat.getDrawable(context, R.drawable.toilet_free_bg);
// Drawable takenBg = ContextCompat.getDrawable(context, R.drawable.toilet_taken_bg);
// view.setBackground(reserved ? takenBg : freeBg);
// }
//
// /**
// * Shows a toast with the methane level
// *
// * @param methane the methane level
// *
// * @param context the context
// */
// public static void showMethaneToast(Integer methane, Context context) {
// String message = "Methane level: " + Integer.toString(methane);
// Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
// }
// }
// Path: vor-android/mobile/src/main/java/com/futurice/vor/fragment/Floor8Fragment.java
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.support.v4.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import com.futurice.vor.R;
import com.futurice.vor.Toilet;
import com.futurice.vor.utils.ToiletUtils;
import java.util.ArrayList;
import butterknife.Bind;
import butterknife.ButterKnife;
mIds.add(Toilet.CM8.getId());
mIds.add(Toilet.CW8.getId());
for (String id : mIds) {
mSharedPreferences.add(mActivity.getSharedPreferences(id, Context.MODE_PRIVATE));
}
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_floor_8_toilet, container, false);
ButterKnife.bind(this, view);
setupView();
return view;
}
private void setupView() {
mRelativeLayouts.add(mToilet8AM);
mRelativeLayouts.add(mToilet8AW);
mRelativeLayouts.add(mToilet8BM);
mRelativeLayouts.add(mToilet8BW);
mRelativeLayouts.add(mToilet8CM);
mRelativeLayouts.add(mToilet8CW);
for (int i = 0; i < mRelativeLayouts.size(); i++) {
RelativeLayout relativeLayout = mRelativeLayouts.get(i);
mOnSharedPreferenceChangeListeners.add((sharedPreferences, key) -> { | ToiletUtils.updateView(sharedPreferences, key, relativeLayout, mActivity); |
chirino/hawtbuf | hawtbuf-protoc/src/main/java/org/fusesource/hawtbuf/proto/compiler/AltJavaGenerator.java | // Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_FIXED32 = 5;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_FIXED64 = 1;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_LENGTH_DELIMITED = 2;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_VARINT = 0;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static int makeTag(int fieldNumber, int wireType) {
// return (fieldNumber << TAG_TYPE_BITS) | wireType;
// }
| import java.util.Map;
import java.util.StringTokenizer;
import org.fusesource.hawtbuf.proto.compiler.parser.ParseException;
import org.fusesource.hawtbuf.proto.compiler.parser.ProtoParser;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_FIXED32;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_FIXED64;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_LENGTH_DELIMITED;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_VARINT;
import static org.fusesource.hawtbuf.proto.WireFormat.makeTag;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap; | p();
p("public " + className + " mergeUnframed(org.fusesource.hawtbuf.proto.CodedInputStream input) throws java.io.IOException {");
indent();
{
p("copyCheck();");
p("while (true) {");
indent();
{
p("int tag = input.readTag();");
p("if ((tag & 0x07) == 4) {");
p(" return this;");
p("}");
p("switch (tag) {");
p("case 0:");
p(" return this;");
p("default: {");
p(" break;");
p("}");
for (FieldDescriptor field : m.getFields().values()) {
String uname = uCamel(field.getName());
String setter = "set" + uname;
boolean repeated = field.getRule() == FieldDescriptor.REPEATED_RULE;
if (repeated) {
setter = "create" + uname + "List().add";
}
if (field.getType() == FieldDescriptor.STRING_TYPE) {
p("case " | // Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_FIXED32 = 5;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_FIXED64 = 1;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_LENGTH_DELIMITED = 2;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_VARINT = 0;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static int makeTag(int fieldNumber, int wireType) {
// return (fieldNumber << TAG_TYPE_BITS) | wireType;
// }
// Path: hawtbuf-protoc/src/main/java/org/fusesource/hawtbuf/proto/compiler/AltJavaGenerator.java
import java.util.Map;
import java.util.StringTokenizer;
import org.fusesource.hawtbuf.proto.compiler.parser.ParseException;
import org.fusesource.hawtbuf.proto.compiler.parser.ProtoParser;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_FIXED32;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_FIXED64;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_LENGTH_DELIMITED;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_VARINT;
import static org.fusesource.hawtbuf.proto.WireFormat.makeTag;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
p();
p("public " + className + " mergeUnframed(org.fusesource.hawtbuf.proto.CodedInputStream input) throws java.io.IOException {");
indent();
{
p("copyCheck();");
p("while (true) {");
indent();
{
p("int tag = input.readTag();");
p("if ((tag & 0x07) == 4) {");
p(" return this;");
p("}");
p("switch (tag) {");
p("case 0:");
p(" return this;");
p("default: {");
p(" break;");
p("}");
for (FieldDescriptor field : m.getFields().values()) {
String uname = uCamel(field.getName());
String setter = "set" + uname;
boolean repeated = field.getRule() == FieldDescriptor.REPEATED_RULE;
if (repeated) {
setter = "create" + uname + "List().add";
}
if (field.getType() == FieldDescriptor.STRING_TYPE) {
p("case " | + makeTag(field.getTag(), |
chirino/hawtbuf | hawtbuf-protoc/src/main/java/org/fusesource/hawtbuf/proto/compiler/AltJavaGenerator.java | // Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_FIXED32 = 5;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_FIXED64 = 1;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_LENGTH_DELIMITED = 2;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_VARINT = 0;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static int makeTag(int fieldNumber, int wireType) {
// return (fieldNumber << TAG_TYPE_BITS) | wireType;
// }
| import java.util.Map;
import java.util.StringTokenizer;
import org.fusesource.hawtbuf.proto.compiler.parser.ParseException;
import org.fusesource.hawtbuf.proto.compiler.parser.ProtoParser;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_FIXED32;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_FIXED64;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_LENGTH_DELIMITED;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_VARINT;
import static org.fusesource.hawtbuf.proto.WireFormat.makeTag;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap; | p("public " + className + " mergeUnframed(org.fusesource.hawtbuf.proto.CodedInputStream input) throws java.io.IOException {");
indent();
{
p("copyCheck();");
p("while (true) {");
indent();
{
p("int tag = input.readTag();");
p("if ((tag & 0x07) == 4) {");
p(" return this;");
p("}");
p("switch (tag) {");
p("case 0:");
p(" return this;");
p("default: {");
p(" break;");
p("}");
for (FieldDescriptor field : m.getFields().values()) {
String uname = uCamel(field.getName());
String setter = "set" + uname;
boolean repeated = field.getRule() == FieldDescriptor.REPEATED_RULE;
if (repeated) {
setter = "create" + uname + "List().add";
}
if (field.getType() == FieldDescriptor.STRING_TYPE) {
p("case "
+ makeTag(field.getTag(), | // Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_FIXED32 = 5;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_FIXED64 = 1;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_LENGTH_DELIMITED = 2;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_VARINT = 0;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static int makeTag(int fieldNumber, int wireType) {
// return (fieldNumber << TAG_TYPE_BITS) | wireType;
// }
// Path: hawtbuf-protoc/src/main/java/org/fusesource/hawtbuf/proto/compiler/AltJavaGenerator.java
import java.util.Map;
import java.util.StringTokenizer;
import org.fusesource.hawtbuf.proto.compiler.parser.ParseException;
import org.fusesource.hawtbuf.proto.compiler.parser.ProtoParser;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_FIXED32;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_FIXED64;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_LENGTH_DELIMITED;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_VARINT;
import static org.fusesource.hawtbuf.proto.WireFormat.makeTag;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
p("public " + className + " mergeUnframed(org.fusesource.hawtbuf.proto.CodedInputStream input) throws java.io.IOException {");
indent();
{
p("copyCheck();");
p("while (true) {");
indent();
{
p("int tag = input.readTag();");
p("if ((tag & 0x07) == 4) {");
p(" return this;");
p("}");
p("switch (tag) {");
p("case 0:");
p(" return this;");
p("default: {");
p(" break;");
p("}");
for (FieldDescriptor field : m.getFields().values()) {
String uname = uCamel(field.getName());
String setter = "set" + uname;
boolean repeated = field.getRule() == FieldDescriptor.REPEATED_RULE;
if (repeated) {
setter = "create" + uname + "List().add";
}
if (field.getType() == FieldDescriptor.STRING_TYPE) {
p("case "
+ makeTag(field.getTag(), | WIRETYPE_LENGTH_DELIMITED) + ":"); |
chirino/hawtbuf | hawtbuf-protoc/src/main/java/org/fusesource/hawtbuf/proto/compiler/AltJavaGenerator.java | // Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_FIXED32 = 5;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_FIXED64 = 1;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_LENGTH_DELIMITED = 2;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_VARINT = 0;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static int makeTag(int fieldNumber, int wireType) {
// return (fieldNumber << TAG_TYPE_BITS) | wireType;
// }
| import java.util.Map;
import java.util.StringTokenizer;
import org.fusesource.hawtbuf.proto.compiler.parser.ParseException;
import org.fusesource.hawtbuf.proto.compiler.parser.ProtoParser;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_FIXED32;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_FIXED64;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_LENGTH_DELIMITED;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_VARINT;
import static org.fusesource.hawtbuf.proto.WireFormat.makeTag;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap; | p("default: {");
p(" break;");
p("}");
for (FieldDescriptor field : m.getFields().values()) {
String uname = uCamel(field.getName());
String setter = "set" + uname;
boolean repeated = field.getRule() == FieldDescriptor.REPEATED_RULE;
if (repeated) {
setter = "create" + uname + "List().add";
}
if (field.getType() == FieldDescriptor.STRING_TYPE) {
p("case "
+ makeTag(field.getTag(),
WIRETYPE_LENGTH_DELIMITED) + ":");
indent();
p(setter + "(input.readString());");
} else if (field.getType() == FieldDescriptor.BYTES_TYPE) {
p("case " + makeTag(field.getTag(), WIRETYPE_LENGTH_DELIMITED) + ":");
indent();
String override = getOption(field.getOptions(), "java_override_type", null);
if ("AsciiBuffer".equals(override)) {
p(setter + "(new org.fusesource.hawtbuf.AsciiBuffer(input.readBytes()));");
} else if ("UTF8Buffer".equals(override)) {
p(setter + "(new org.fusesource.hawtbuf.UTF8Buffer(input.readBytes()));");
} else {
p(setter + "(input.readBytes());");
}
} else if (field.getType() == FieldDescriptor.BOOL_TYPE) { | // Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_FIXED32 = 5;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_FIXED64 = 1;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_LENGTH_DELIMITED = 2;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static final int WIRETYPE_VARINT = 0;
//
// Path: hawtbuf-proto/src/main/java/org/fusesource/hawtbuf/proto/WireFormat.java
// public static int makeTag(int fieldNumber, int wireType) {
// return (fieldNumber << TAG_TYPE_BITS) | wireType;
// }
// Path: hawtbuf-protoc/src/main/java/org/fusesource/hawtbuf/proto/compiler/AltJavaGenerator.java
import java.util.Map;
import java.util.StringTokenizer;
import org.fusesource.hawtbuf.proto.compiler.parser.ParseException;
import org.fusesource.hawtbuf.proto.compiler.parser.ProtoParser;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_FIXED32;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_FIXED64;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_LENGTH_DELIMITED;
import static org.fusesource.hawtbuf.proto.WireFormat.WIRETYPE_VARINT;
import static org.fusesource.hawtbuf.proto.WireFormat.makeTag;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
p("default: {");
p(" break;");
p("}");
for (FieldDescriptor field : m.getFields().values()) {
String uname = uCamel(field.getName());
String setter = "set" + uname;
boolean repeated = field.getRule() == FieldDescriptor.REPEATED_RULE;
if (repeated) {
setter = "create" + uname + "List().add";
}
if (field.getType() == FieldDescriptor.STRING_TYPE) {
p("case "
+ makeTag(field.getTag(),
WIRETYPE_LENGTH_DELIMITED) + ":");
indent();
p(setter + "(input.readString());");
} else if (field.getType() == FieldDescriptor.BYTES_TYPE) {
p("case " + makeTag(field.getTag(), WIRETYPE_LENGTH_DELIMITED) + ":");
indent();
String override = getOption(field.getOptions(), "java_override_type", null);
if ("AsciiBuffer".equals(override)) {
p(setter + "(new org.fusesource.hawtbuf.AsciiBuffer(input.readBytes()));");
} else if ("UTF8Buffer".equals(override)) {
p(setter + "(new org.fusesource.hawtbuf.UTF8Buffer(input.readBytes()));");
} else {
p(setter + "(input.readBytes());");
}
} else if (field.getType() == FieldDescriptor.BOOL_TYPE) { | p("case " + makeTag(field.getTag(), WIRETYPE_VARINT) + ":"); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.