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
hprange/woinject
src/main/java/com/webobjects/foundation/InstantiationInterceptor.java
// Path: src/main/java/com/woinject/InjectableApplication.java // public abstract class InjectableApplication extends ERXApplication { // public static InjectableApplication application() { // return (InjectableApplication) WOApplication.application(); // } // // private final Injector injector; //...
import com.google.inject.Injector; import com.woinject.InjectableApplication; import com.woinject.WOInjectException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.reflect.Constructor;
/** * Copyright (C) 2010 hprange <hprange@gmail.com> * * 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 ...
// Path: src/main/java/com/woinject/InjectableApplication.java // public abstract class InjectableApplication extends ERXApplication { // public static InjectableApplication application() { // return (InjectableApplication) WOApplication.application(); // } // // private final Injector injector; //...
throw new WOInjectException("The instantiation of " + type.getName() + " class has failed.", exception);
hprange/woinject
src/main/java/com/webobjects/foundation/InstantiationInterceptor.java
// Path: src/main/java/com/woinject/InjectableApplication.java // public abstract class InjectableApplication extends ERXApplication { // public static InjectableApplication application() { // return (InjectableApplication) WOApplication.application(); // } // // private final Injector injector; //...
import com.google.inject.Injector; import com.woinject.InjectableApplication; import com.woinject.WOInjectException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.reflect.Constructor;
/** * Copyright (C) 2010 hprange <hprange@gmail.com> * * 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 ...
// Path: src/main/java/com/woinject/InjectableApplication.java // public abstract class InjectableApplication extends ERXApplication { // public static InjectableApplication application() { // return (InjectableApplication) WOApplication.application(); // } // // private final Injector injector; //...
InjectableApplication application = InjectableApplication.application();
hprange/woinject
src/test/java/com/woinject/TestWOSessionProvider.java
// Path: src/test/java/com/woinject/stubs/StubApplication.java // public class StubApplication extends InjectableApplication { // private static class StubModule extends AbstractModule { // private boolean moduleWasLoaded = false; // // @Override // protected void configure() { // ...
import er.extensions.appserver.ERXSession; import er.extensions.appserver.ERXWOContext; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.when; import org.junit.After; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedExce...
ERXSession.setSession(null); ERXWOContext.setCurrentContext(null); } @Test public void returnSessionFromERXSession() throws Exception { ERXSession.setSession(session); WOSessionProvider<ERXSession> provider = new WOSessionProvider<ERXSession>(); assertThat(provider...
// Path: src/test/java/com/woinject/stubs/StubApplication.java // public class StubApplication extends InjectableApplication { // private static class StubModule extends AbstractModule { // private boolean moduleWasLoaded = false; // // @Override // protected void configure() { // ...
StubApplication.setApplication(application);
hprange/woinject
src/test/java/com/woinject/TestWOSessionScope.java
// Path: src/test/java/com/woinject/stubs/StubApplication.java // public class StubApplication extends InjectableApplication { // private static class StubModule extends AbstractModule { // private boolean moduleWasLoaded = false; // // @Override // protected void configure() { // ...
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.nullValue; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.when; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.m...
/** * Copyright (C) 2010 hprange <hprange@gmail.com> * * 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 applicab...
// Path: src/test/java/com/woinject/stubs/StubApplication.java // public class StubApplication extends InjectableApplication { // private static class StubModule extends AbstractModule { // private boolean moduleWasLoaded = false; // // @Override // protected void configure() { // ...
StubApplication.setApplication(application);
hprange/woinject
src/test/java/com/woinject/TestInjectableApplication.java
// Path: src/test/java/com/woinject/stubs/StubApplication.java // public class StubApplication extends InjectableApplication { // private static class StubModule extends AbstractModule { // private boolean moduleWasLoaded = false; // // @Override // protected void configure() { // ...
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertThat; import org.junit.After; import org.junit.Test; import com.google.inject.Injector; import com.google.inject.Stage; import com.woinject.stubs.StubApplication; import er.extensions.f...
/** * Copyright (C) 2010 hprange <hprange@gmail.com> * * 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 ...
// Path: src/test/java/com/woinject/stubs/StubApplication.java // public class StubApplication extends InjectableApplication { // private static class StubModule extends AbstractModule { // private boolean moduleWasLoaded = false; // // @Override // protected void configure() { // ...
assertThat(((StubApplication) application).stubModuleWasLoaded(), is(true));
gesellix/Nimbus-JOSE-JWT
src/test/java/com/nimbusds/jose/JWSHeaderTest.java
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
import java.text.ParseException; import junit.framework.TestCase; import com.nimbusds.jose.util.Base64URL;
package com.nimbusds.jose; /** * Tests JWS header parsing and serialisation. * * @author Vladimir Dzhuvinov * @version $version$ (2012-10-01) */ public class JWSHeaderTest extends TestCase { public void testParseJSONText() { // Example header from JWS spec String s = "{\"typ\":\"JWT\",\"alg\":\...
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
h = JWSHeader.parse(new Base64URL(s));
gesellix/Nimbus-JOSE-JWT
src/main/java/com/nimbusds/jose/ReadOnlyJWEHeader.java
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
import com.nimbusds.jose.util.Base64URL;
package com.nimbusds.jose; /** * Read-only view of a {@link JWEHeader JWE header}. * * @author Vladimir Dzhuvinov * @version $version$ (2012-10-16) */ public interface ReadOnlyJWEHeader extends ReadOnlyCommonSEHeader { /** * Gets the algorithm ({@code alg}) parameter. * * @return The algorithm paramet...
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
public Base64URL getAgreementPartyUInfo();
gesellix/Nimbus-JOSE-JWT
src/main/java/com/nimbusds/jose/JWEDecrypter.java
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
import java.util.Set; import com.nimbusds.jose.util.Base64URL;
package com.nimbusds.jose; /** * Interface for decrypting JSON Web Encryption (JWE) objects. * * <p>Callers can query the decrypter to determine its algorithm capabilities as * well as the JWE algorithms and header parameters that are accepted for * processing. * * @author Vladimir Dzhuvinov * @version $v...
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
final Base64URL encryptedKey,
gesellix/Nimbus-JOSE-JWT
src/test/java/com/nimbusds/jose/PlainHeaderTest.java
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
import java.text.ParseException; import junit.framework.TestCase; import com.nimbusds.jose.util.Base64URL;
package com.nimbusds.jose; /** * Tests plain header parsing and serialisation. * * @author Vladimir Dzhuvinov * @version $version$ (2012-10-01) */ public class PlainHeaderTest extends TestCase { public void testSerializeAndParse() { PlainHeader h = new PlainHeader(); assertEquals(Algorithm.NONE...
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
Base64URL b64url = h.toBase64URL();
gesellix/Nimbus-JOSE-JWT
src/test/java/com/nimbusds/jose/crypto/DefaultJWSHeaderFilterTest.java
// Path: src/main/java/com/nimbusds/jose/JWSAlgorithm.java // @Immutable // public final class JWSAlgorithm extends Algorithm { // // // /** // * HMAC using SHA-256 hash algorithm (required). // */ // public static final JWSAlgorithm HS256 = new JWSAlgorithm("HS256", Requirement.REQUIRED); // // // /** // ...
import java.util.HashSet; import java.util.Set; import junit.framework.TestCase; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jose.JWSHeaderFilter;
package com.nimbusds.jose.crypto; /** * Tests the default JWS header filter implementation. * * @author Vladimir Dzhuvinov * @version $version$ (2012-10-05) */ public class DefaultJWSHeaderFilterTest extends TestCase { public void testRun() {
// Path: src/main/java/com/nimbusds/jose/JWSAlgorithm.java // @Immutable // public final class JWSAlgorithm extends Algorithm { // // // /** // * HMAC using SHA-256 hash algorithm (required). // */ // public static final JWSAlgorithm HS256 = new JWSAlgorithm("HS256", Requirement.REQUIRED); // // // /** // ...
Set<JWSAlgorithm> supportedAlgs = new HashSet<JWSAlgorithm>();
gesellix/Nimbus-JOSE-JWT
src/test/java/com/nimbusds/jose/JOSEObjectTest.java
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
import java.text.ParseException; import junit.framework.TestCase; import com.nimbusds.jose.util.Base64URL;
package com.nimbusds.jose; /** * Tests JOSE object methods. * * @author Vladimir Dzhuvinov * @version $version$ (2012-10-16) */ public class JOSEObjectTest extends TestCase { public void testSplitThreeParts() { // Implies JWS String s = "abc.def.ghi";
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
Base64URL[] parts = null;
gesellix/Nimbus-JOSE-JWT
src/main/java/com/nimbusds/jose/PlainObject.java
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
import java.text.ParseException; import net.jcip.annotations.ThreadSafe; import com.nimbusds.jose.util.Base64URL;
package com.nimbusds.jose; /** * Plaintext (unsecured) JOSE object. This class is thread-safe. * * @author Vladimir Dzhuvinov * @version $version$ (2012-10-23) */ @ThreadSafe public class PlainObject extends JOSEObject { /** * The header. */ private final PlainHeader header; /** * Creates a n...
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
public PlainObject(final Base64URL firstPart, final Base64URL secondPart)
gesellix/Nimbus-JOSE-JWT
src/test/java/com/nimbusds/jose/JWKSetTest.java
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
import com.nimbusds.jose.util.Base64URL; import java.text.ParseException; import java.util.List; import junit.framework.TestCase;
assertEquals("4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM", ecKey.getY().toString()); key = keyList.get(1); assertNotNull(key); assertTrue(key instanceof RSAKey); assertEquals("2011-04-29", key.getKeyID()); assertNull(key.getKeyUse()); RSAKey rsaKey = (RSAKey)key; assertEquals("0vx7ag...
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
new Base64URL("abc"),
gesellix/Nimbus-JOSE-JWT
src/main/java/com/nimbusds/jose/JWEObject.java
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
import java.text.ParseException; import net.jcip.annotations.ThreadSafe; import com.nimbusds.jose.util.Base64URL;
package com.nimbusds.jose; /** * JSON Web Encryption (JWE) object. This class is thread-safe. * * @author Vladimir Dzhuvinov * @version $version$ (2012-10-23) */ @ThreadSafe public class JWEObject extends JOSEObject { /** * Enumeration of the states of a JSON Web Encryption (JWE) object. */ public st...
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
private Base64URL encryptedKey;
gesellix/Nimbus-JOSE-JWT
src/main/java/com/nimbusds/jose/JWSObject.java
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
import java.io.UnsupportedEncodingException; import java.text.ParseException; import java.util.Set; import net.jcip.annotations.ThreadSafe; import com.nimbusds.jose.util.Base64URL;
package com.nimbusds.jose; /** * JSON Web Signature (JWS) object. This class is thread-safe. * * @author Vladimir Dzhuvinov * @version $version$ (2012-10-23) */ @ThreadSafe public class JWSObject extends JOSEObject { /** * Enumeration of the states of a JSON Web Signature (JWS) object. */ public st...
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
private Base64URL signature;
gesellix/Nimbus-JOSE-JWT
src/main/java/com/nimbusds/jose/JWECryptoParts.java
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
import net.jcip.annotations.Immutable; import com.nimbusds.jose.util.Base64URL;
package com.nimbusds.jose; /** * The cryptographic parts of a JSON Web Encryption (JWE) object. This class is * an immutable simple wrapper for returning the cipher text, initialisation * vector (IV), encrypted key and integrity value from {@link JWEEncrypter} * implementations. * * @author Vladimir Dzhuv...
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
private final Base64URL encryptedKey;
gesellix/Nimbus-JOSE-JWT
src/main/java/com/nimbusds/jose/crypto/DefaultJWSHeaderFilter.java
// Path: src/main/java/com/nimbusds/jose/JWSAlgorithm.java // @Immutable // public final class JWSAlgorithm extends Algorithm { // // // /** // * HMAC using SHA-256 hash algorithm (required). // */ // public static final JWSAlgorithm HS256 = new JWSAlgorithm("HS256", Requirement.REQUIRED); // // // /** // ...
import java.util.Collections; import java.util.Set; import net.jcip.annotations.ThreadSafe; import com.nimbusds.jose.JWSAlgorithm; import com.nimbusds.jose.JWSHeaderFilter;
package com.nimbusds.jose.crypto; /** * JSON Web Signature (JWS) header filter implementation. This class is * thread-safe. * * @author Vladimir Dzhuvinov * @version $version$ (2012-10-23) */ @ThreadSafe class DefaultJWSHeaderFilter implements JWSHeaderFilter { /** * The supported algorithms. Used to ...
// Path: src/main/java/com/nimbusds/jose/JWSAlgorithm.java // @Immutable // public final class JWSAlgorithm extends Algorithm { // // // /** // * HMAC using SHA-256 hash algorithm (required). // */ // public static final JWSAlgorithm HS256 = new JWSAlgorithm("HS256", Requirement.REQUIRED); // // // /** // ...
private final Set<JWSAlgorithm> algs;
gesellix/Nimbus-JOSE-JWT
src/main/java/com/nimbusds/jose/JWSVerifier.java
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
import com.nimbusds.jose.util.Base64URL;
package com.nimbusds.jose; /** * Interface for verifying JSON Web Signature (JWS) objects. * * <p>Callers can query the verifier to determine its algorithm capabilities as * well as the JWS algorithms and header parameters that are accepted for * processing. * * @author Vladimir Dzhuvinov * @version $versi...
// Path: src/main/java/com/nimbusds/jose/util/Base64URL.java // @Immutable // public class Base64URL implements JSONAware { // // // /** // * UTF-8 is the required charset for all JWTs. // */ // private static final String CHARSET = "utf-8"; // // // /** // * The Base64URL value. // */ // private fina...
final Base64URL signature)
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/GoOfflineMojo.java
// Path: src/main/java/org/simplify4u/plugins/pgp/SignatureCheckResult.java // @Value // @Builder // public class SignatureCheckResult { // // @NonNull // ArtifactInfo artifact; // // KeyInfo key; // /** // * Last address for key search. // */ // String keyShowUrl; // // SignatureIn...
import java.util.Collection; import java.util.Optional; import java.util.Set; import lombok.extern.slf4j.Slf4j; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.simplify4u.plugins.pgp.SignatureCheckResult...
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/main/java/org/simplify4u/plugins/pgp/SignatureCheckResult.java // @Value // @Builder // public class SignatureCheckResult { // // @NonNull // ArtifactInfo artifact; // // KeyInfo key; // /** // * Last address for key search. // */ // String keyShowUrl; // // SignatureIn...
SignatureCheckResult checkResult = signatureUtils.resolveSignature(artifact, ascArtifact, pgpKeysCache);
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/GoOfflineMojo.java
// Path: src/main/java/org/simplify4u/plugins/pgp/SignatureCheckResult.java // @Value // @Builder // public class SignatureCheckResult { // // @NonNull // ArtifactInfo artifact; // // KeyInfo key; // /** // * Last address for key search. // */ // String keyShowUrl; // // SignatureIn...
import java.util.Collection; import java.util.Optional; import java.util.Set; import lombok.extern.slf4j.Slf4j; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.simplify4u.plugins.pgp.SignatureCheckResult...
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/main/java/org/simplify4u/plugins/pgp/SignatureCheckResult.java // @Value // @Builder // public class SignatureCheckResult { // // @NonNull // ArtifactInfo artifact; // // KeyInfo key; // /** // * Last address for key search. // */ // String keyShowUrl; // // SignatureIn...
if (checkResult.getStatus() != SignatureStatus.RESOLVED) {
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/pgp/ReportsUtilsTest.java
// Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static SignatureCheckResult.SignatureCheckResultBuilder aSignatureCheckResultBuilder(Date date) { // return SignatureCheckResult.builder() // .artifact(ArtifactInfo.builder() // .groupId("groupId") // ...
import java.io.File; import java.io.IOException; import java.time.ZonedDateTime; import java.util.Arrays; import java.util.Collections; import java.util.Date; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.simplify4u.plugins....
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static SignatureCheckResult.SignatureCheckResultBuilder aSignatureCheckResultBuilder(Date date) { // return SignatureCheckResult.builder() // .artifact(ArtifactInfo.builder() // .groupId("groupId") // ...
SignatureCheckResult checkResult1 = aSignatureCheckResultBuilder(date1)
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/pgp/PublicKeyUtils.java
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // @UtilityClass // public class HexUtils { // // /** // * Convert byte array of fingerprint to string of hex // * @param bytes fingerprint // * @return fingerprint as string // */ // public static String fingerprintToString(...
import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.Optional; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors;...
/* * Copyright 2020-2021 Slawomir Jaranowski * * 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 ...
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // @UtilityClass // public class HexUtils { // // /** // * Convert byte array of fingerprint to string of hex // * @param bytes fingerprint // * @return fingerprint as string // */ // public static String fingerprintToString(...
return HexUtils.fingerprintToString(publicKey.getFingerprint());
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/keysmap/KeyItems.java
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java // @Builder // @Value // public class KeyInfo { // // @NonNull // KeyFingerprint fingerprint; // // KeyFingerprint master; // // Collection<String> uids; // // int version; // int algorithm; // // int bits; // // Date d...
import java.util.ArrayList; import java.util.Arrays; import java.util.List; import lombok.extern.slf4j.Slf4j; import org.simplify4u.plugins.pgp.KeyInfo;
} /** * Add keys from another KeyItems. * * @param keyItems a keyItem with key to add * @param keysMapContext a context of current processing * * @return a current object instance */ public KeyItems addKeys(KeyItems keyItems, KeysMapContext keysMapContext) { ...
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java // @Builder // @Value // public class KeyInfo { // // @NonNull // KeyFingerprint fingerprint; // // KeyFingerprint master; // // Collection<String> uids; // // int version; // int algorithm; // // int bits; // // Date d...
public boolean isKeyMatch(KeyInfo keyInfo) {
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/ShowMojo.java
// Path: src/main/java/org/simplify4u/plugins/pgp/ArtifactInfo.java // @Value // @Builder // public class ArtifactInfo { // // @NonNull // String groupId; // // @NonNull // String artifactId; // // @NonNull // String type; // // @NonNull // String version; // // String classifie...
import java.util.HashSet; import java.util.Map; import java.util.Optional; import java.util.Set; import javax.inject.Inject; import io.vavr.control.Try; import lombok.AccessLevel; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.annotatio...
} @Override protected void executeConfiguredMojo() { Set<Artifact> artifactsToCheck = new HashSet<>(); Artifact artifactToCheck = prepareArtifactToCheck(); artifactsToCheck.add(artifactResolver.resolveArtifact(artifactToCheck)); if (showPom && artifactToCheck.isResolved()...
// Path: src/main/java/org/simplify4u/plugins/pgp/ArtifactInfo.java // @Value // @Builder // public class ArtifactInfo { // // @NonNull // String groupId; // // @NonNull // String artifactId; // // @NonNull // String type; // // @NonNull // String version; // // String classifie...
SignatureCheckResult signatureCheckResult = signatureUtils.checkSignature(artifactToCheck, sig, pgpKeysCache);
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/ShowMojo.java
// Path: src/main/java/org/simplify4u/plugins/pgp/ArtifactInfo.java // @Value // @Builder // public class ArtifactInfo { // // @NonNull // String groupId; // // @NonNull // String artifactId; // // @NonNull // String type; // // @NonNull // String version; // // String classifie...
import java.util.HashSet; import java.util.Map; import java.util.Optional; import java.util.Set; import javax.inject.Inject; import io.vavr.control.Try; import lombok.AccessLevel; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.annotatio...
Artifact artifactToCheck = prepareArtifactToCheck(); artifactsToCheck.add(artifactResolver.resolveArtifact(artifactToCheck)); if (showPom && artifactToCheck.isResolved()) { artifactsToCheck.add(artifactResolver.resolvePom(artifactToCheck)); } Map<Artifact, Artifact...
// Path: src/main/java/org/simplify4u/plugins/pgp/ArtifactInfo.java // @Value // @Builder // public class ArtifactInfo { // // @NonNull // String groupId; // // @NonNull // String artifactId; // // @NonNull // String type; // // @NonNull // String version; // // String classifie...
ArtifactInfo artifactInfo = signatureCheckResult.getArtifact();
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/ShowMojo.java
// Path: src/main/java/org/simplify4u/plugins/pgp/ArtifactInfo.java // @Value // @Builder // public class ArtifactInfo { // // @NonNull // String groupId; // // @NonNull // String artifactId; // // @NonNull // String type; // // @NonNull // String version; // // String classifie...
import java.util.HashSet; import java.util.Map; import java.util.Optional; import java.util.Set; import javax.inject.Inject; import io.vavr.control.Try; import lombok.AccessLevel; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.annotatio...
Boolean result = artifactMap.entrySet().stream() .map(this::processArtifact) .reduce(true, (a, b) -> a && b); if (Boolean.FALSE.equals(result)) { throw new PGPMojoException("Some of artifact can't be checked"); } } private boolean processArt...
// Path: src/main/java/org/simplify4u/plugins/pgp/ArtifactInfo.java // @Value // @Builder // public class ArtifactInfo { // // @NonNull // String groupId; // // @NonNull // String artifactId; // // @NonNull // String type; // // @NonNull // String version; // // String classifie...
if (signatureCheckResult.getStatus() == SignatureStatus.ARTIFACT_NOT_RESOLVED) {
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/ShowMojo.java
// Path: src/main/java/org/simplify4u/plugins/pgp/ArtifactInfo.java // @Value // @Builder // public class ArtifactInfo { // // @NonNull // String groupId; // // @NonNull // String artifactId; // // @NonNull // String type; // // @NonNull // String version; // // String classifie...
import java.util.HashSet; import java.util.Map; import java.util.Optional; import java.util.Set; import javax.inject.Inject; import io.vavr.control.Try; import lombok.AccessLevel; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.annotatio...
throw new PGPMojoException("Some of artifact can't be checked"); } } private boolean processArtifact(Map.Entry<Artifact, Artifact> artifactEntry) { Artifact artifactToCheck = artifactEntry.getKey(); Artifact sig = artifactEntry.getValue(); SignatureCheckResult sign...
// Path: src/main/java/org/simplify4u/plugins/pgp/ArtifactInfo.java // @Value // @Builder // public class ArtifactInfo { // // @NonNull // String groupId; // // @NonNull // String artifactId; // // @NonNull // String type; // // @NonNull // String version; // // String classifie...
SignatureInfo signature = signatureCheckResult.getSignature();
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/ShowMojo.java
// Path: src/main/java/org/simplify4u/plugins/pgp/ArtifactInfo.java // @Value // @Builder // public class ArtifactInfo { // // @NonNull // String groupId; // // @NonNull // String artifactId; // // @NonNull // String type; // // @NonNull // String version; // // String classifie...
import java.util.HashSet; import java.util.Map; import java.util.Optional; import java.util.Set; import javax.inject.Inject; import io.vavr.control.Try; import lombok.AccessLevel; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugins.annotatio...
if (signatureCheckResult.getStatus() == SignatureStatus.ARTIFACT_NOT_RESOLVED) { messageBuilder.a("\t").failure("artifact was not resolved - try mvn -U ...").newline(); } messageBuilder.newline(); SignatureInfo signature = signatureCheckResult.getSignature(); if (s...
// Path: src/main/java/org/simplify4u/plugins/pgp/ArtifactInfo.java // @Value // @Builder // public class ArtifactInfo { // // @NonNull // String groupId; // // @NonNull // String artifactId; // // @NonNull // String type; // // @NonNull // String version; // // String classifie...
KeyInfo key = signatureCheckResult.getKey();
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/keysmap/KeyItemFingerprint.java
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // public static byte[] stringToFingerprint(String key) { // byte[] bytes; // // try { // bytes = Hex.decode(key.substring(2)); // } catch (DecoderException e) { // throw new IllegalArgumentException("Malformed keyID hex stri...
import java.util.Optional; import static org.simplify4u.plugins.utils.HexUtils.stringToFingerprint; import lombok.EqualsAndHashCode; import org.simplify4u.plugins.pgp.KeyFingerprint; import org.simplify4u.plugins.pgp.KeyInfo; import org.simplify4u.plugins.utils.HexUtils;
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // public static byte[] stringToFingerprint(String key) { // byte[] bytes; // // try { // bytes = Hex.decode(key.substring(2)); // } catch (DecoderException e) { // throw new IllegalArgumentException("Malformed keyID hex stri...
fingerPrint = stringToFingerprint(key);
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/keysmap/KeyItemFingerprint.java
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // public static byte[] stringToFingerprint(String key) { // byte[] bytes; // // try { // bytes = Hex.decode(key.substring(2)); // } catch (DecoderException e) { // throw new IllegalArgumentException("Malformed keyID hex stri...
import java.util.Optional; import static org.simplify4u.plugins.utils.HexUtils.stringToFingerprint; import lombok.EqualsAndHashCode; import org.simplify4u.plugins.pgp.KeyFingerprint; import org.simplify4u.plugins.pgp.KeyInfo; import org.simplify4u.plugins.utils.HexUtils;
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // public static byte[] stringToFingerprint(String key) { // byte[] bytes; // // try { // bytes = Hex.decode(key.substring(2)); // } catch (DecoderException e) { // throw new IllegalArgumentException("Malformed keyID hex stri...
public boolean isKeyMatch(KeyInfo keyInfo) {
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/keysmap/KeyItemFingerprint.java
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // public static byte[] stringToFingerprint(String key) { // byte[] bytes; // // try { // bytes = Hex.decode(key.substring(2)); // } catch (DecoderException e) { // throw new IllegalArgumentException("Malformed keyID hex stri...
import java.util.Optional; import static org.simplify4u.plugins.utils.HexUtils.stringToFingerprint; import lombok.EqualsAndHashCode; import org.simplify4u.plugins.pgp.KeyFingerprint; import org.simplify4u.plugins.pgp.KeyInfo; import org.simplify4u.plugins.utils.HexUtils;
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // public static byte[] stringToFingerprint(String key) { // byte[] bytes; // // try { // bytes = Hex.decode(key.substring(2)); // } catch (DecoderException e) { // throw new IllegalArgumentException("Malformed keyID hex stri...
private boolean compareWith(KeyFingerprint fingerprint) {
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/keysmap/KeyItemFingerprint.java
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // public static byte[] stringToFingerprint(String key) { // byte[] bytes; // // try { // bytes = Hex.decode(key.substring(2)); // } catch (DecoderException e) { // throw new IllegalArgumentException("Malformed keyID hex stri...
import java.util.Optional; import static org.simplify4u.plugins.utils.HexUtils.stringToFingerprint; import lombok.EqualsAndHashCode; import org.simplify4u.plugins.pgp.KeyFingerprint; import org.simplify4u.plugins.pgp.KeyInfo; import org.simplify4u.plugins.utils.HexUtils;
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // public static byte[] stringToFingerprint(String key) { // byte[] bytes; // // try { // bytes = Hex.decode(key.substring(2)); // } catch (DecoderException e) { // throw new IllegalArgumentException("Malformed keyID hex stri...
return HexUtils.fingerprintToString(fingerPrint);
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/pgp/KeyId.java
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // public static String fingerprintToString(byte[] bytes) { // StringBuilder ret = new StringBuilder(); // ret.append("0x"); // for (byte b : bytes) { // ret.append(String.format("%02X", b)); // } // return ret.toString(); // ...
import static org.simplify4u.plugins.utils.HexUtils.fingerprintToString; import com.fasterxml.jackson.annotation.JsonValue; import lombok.EqualsAndHashCode; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpgp.PGPPublicKeyRing; import org.bouncycast...
KeyIdFingerprint(byte[] fingerprint) { this.fingerprint = fingerprint; } @Override public String getHashPath() { StringBuilder ret = new StringBuilder(); ret.append(String.format("%02X/", fingerprint[0])); ret.append(String.format("%02X/",...
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // public static String fingerprintToString(byte[] bytes) { // StringBuilder ret = new StringBuilder(); // ret.append("0x"); // for (byte b : bytes) { // ret.append(String.format("%02X", b)); // } // return ret.toString(); // ...
return fingerprintToString(fingerprint);
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/keysmap/KeyItemAnyKey.java
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java // @Builder // @Value // public class KeyInfo { // // @NonNull // KeyFingerprint fingerprint; // // KeyFingerprint master; // // Collection<String> uids; // // int version; // int algorithm; // // int bits; // // Date d...
import lombok.EqualsAndHashCode; import org.simplify4u.plugins.pgp.KeyInfo;
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java // @Builder // @Value // public class KeyInfo { // // @NonNull // KeyFingerprint fingerprint; // // KeyFingerprint master; // // Collection<String> uids; // // int version; // int algorithm; // // int bits; // // Date d...
public boolean isKeyMatch(KeyInfo keyInfo) {
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keysmap/KeysMapTest.java
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeyInfo aKeyInfo(String fingerprint) { // return KeyInfo.builde...
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Argume...
/* * Copyright 2020 Slawomir Jaranowski * * 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 ag...
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeyInfo aKeyInfo(String fingerprint) { // return KeyInfo.builde...
assertThat(keysMap.isValidKey(testArtifact().build(), null)).isTrue();
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keysmap/KeysMapTest.java
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeyInfo aKeyInfo(String fingerprint) { // return KeyInfo.builde...
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Argume...
/* * Copyright 2020 Slawomir Jaranowski * * 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 ag...
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeyInfo aKeyInfo(String fingerprint) { // return KeyInfo.builde...
keysMap.load(aKeysMapLocationConfig(""));
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keysmap/KeysMapTest.java
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeyInfo aKeyInfo(String fingerprint) { // return KeyInfo.builde...
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Argume...
public void nullLocationTest() throws Exception { assertThatThrownBy(() -> keysMap.load(null)) .isExactlyInstanceOf(NullPointerException.class); verifyNoInteractions(resourceManager); assertThat(keysMap.isValidKey(testArtifact().build(), null)).isTrue(); } @Test ...
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeyInfo aKeyInfo(String fingerprint) { // return KeyInfo.builde...
aKeyInfo("0x123456789abcdef0"))
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/utils/MavenCompilerUtilsTest.java
// Path: src/main/java/org/simplify4u/plugins/utils/MavenCompilerUtils.java // public static boolean checkCompilerPlugin(Plugin plugin) { // return GROUPID.equals(plugin.getGroupId()) && ARTIFACTID.equals(plugin.getArtifactId()); // } // // Path: src/main/java/org/simplify4u/plugins/utils/MavenCompilerUtils.java /...
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertThrows; import static org.testng.Assert.assertTrue; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Plugin; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.util.xml.Xpp3Dom; import...
/* * Copyright 2019 Danny van Heumen * * 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 agree...
// Path: src/main/java/org/simplify4u/plugins/utils/MavenCompilerUtils.java // public static boolean checkCompilerPlugin(Plugin plugin) { // return GROUPID.equals(plugin.getGroupId()) && ARTIFACTID.equals(plugin.getArtifactId()); // } // // Path: src/main/java/org/simplify4u/plugins/utils/MavenCompilerUtils.java /...
assertThrows(NullPointerException.class, () -> checkCompilerPlugin(null));
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/utils/MavenCompilerUtilsTest.java
// Path: src/main/java/org/simplify4u/plugins/utils/MavenCompilerUtils.java // public static boolean checkCompilerPlugin(Plugin plugin) { // return GROUPID.equals(plugin.getGroupId()) && ARTIFACTID.equals(plugin.getArtifactId()); // } // // Path: src/main/java/org/simplify4u/plugins/utils/MavenCompilerUtils.java /...
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertThrows; import static org.testng.Assert.assertTrue; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Plugin; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.util.xml.Xpp3Dom; import...
/* * Copyright 2019 Danny van Heumen * * 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 agree...
// Path: src/main/java/org/simplify4u/plugins/utils/MavenCompilerUtils.java // public static boolean checkCompilerPlugin(Plugin plugin) { // return GROUPID.equals(plugin.getGroupId()) && ARTIFACTID.equals(plugin.getArtifactId()); // } // // Path: src/main/java/org/simplify4u/plugins/utils/MavenCompilerUtils.java /...
assertThrows(NullPointerException.class, () -> extractAnnotationProcessors(null, null));
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keysmap/KeysMapMultiTest.java
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeysMapLocationConfig aKeysMapLocationConfig(String location) { // ...
import org.simplify4u.plugins.pgp.KeyInfo; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import java.io.IOException; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito....
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeysMapLocationConfig aKeysMapLocationConfig(String location) { // ...
keysMap.load(aKeysMapLocationConfig("/keysMapMulti1.list"));
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keysmap/KeysMapMultiTest.java
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeysMapLocationConfig aKeysMapLocationConfig(String location) { // ...
import org.simplify4u.plugins.pgp.KeyInfo; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import java.io.IOException; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito....
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeysMapLocationConfig aKeysMapLocationConfig(String location) { // ...
{testArtifact().build(),
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keysmap/KeysMapMultiTest.java
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeysMapLocationConfig aKeysMapLocationConfig(String location) { // ...
import org.simplify4u.plugins.pgp.KeyInfo; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import java.io.IOException; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito....
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeysMapLocationConfig aKeysMapLocationConfig(String location) { // ...
new KeyFingerprint("0x1111 1111 1111 1111")},
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keysmap/KeysMapMultiTest.java
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeysMapLocationConfig aKeysMapLocationConfig(String location) { // ...
import org.simplify4u.plugins.pgp.KeyInfo; import org.testng.annotations.BeforeMethod; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import java.io.IOException; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito....
{testArtifact().build(), new KeyFingerprint("0x1111 1111 3333 3333")}, {testArtifact().artifactId("test1").build(), new KeyFingerprint("0x1111 1111 4444 4444")}, {testArtifact().build(), new KeyFing...
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // // Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeysMapLocationConfig aKeysMapLocationConfig(String location) { // ...
KeyInfo key = KeyInfo.builder().fingerprint(keyFingerprint).build();
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keysmap/KeyItemsTest.java
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyFingerprint.java // @Value // @RequiredArgsConstructor // public class KeyFingerprint { // // byte[] fingerprint; // // /** // * Construct a key fingerprint from string representation. // * @param strFingerprint a key fingerprint as string // ...
import java.io.IOException; import java.util.Collections; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.bouncycastle.openpgp.PGPException; im...
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyFingerprint.java // @Value // @RequiredArgsConstructor // public class KeyFingerprint { // // byte[] fingerprint; // // /** // * Construct a key fingerprint from string representation. // * @param strFingerprint a key fingerprint as string // ...
private KeyInfo aKeyInfo(String fingerprint) {
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keysmap/KeyItemsTest.java
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyFingerprint.java // @Value // @RequiredArgsConstructor // public class KeyFingerprint { // // byte[] fingerprint; // // /** // * Construct a key fingerprint from string representation. // * @param strFingerprint a key fingerprint as string // ...
import java.io.IOException; import java.util.Collections; import static java.util.Arrays.asList; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.bouncycastle.openpgp.PGPException; im...
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyFingerprint.java // @Value // @RequiredArgsConstructor // public class KeyFingerprint { // // byte[] fingerprint; // // /** // * Construct a key fingerprint from string representation. // * @param strFingerprint a key fingerprint as string // ...
return KeyInfo.builder().fingerprint(new KeyFingerprint(fingerprint)).build();
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keysmap/ArtifactPatternTest.java
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // }
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.simplify4u.plugins.TestArtifactBuilder.testArtifact; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; impo...
/* * Copyright 2020-2021 Slawomir Jaranowski * * 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 ...
// Path: src/test/java/org/simplify4u/plugins/TestArtifactBuilder.java // public static TestArtifactBuilder testArtifact() { // return new TestArtifactBuilder(); // } // Path: src/test/java/org/simplify4u/plugins/keysmap/ArtifactPatternTest.java import static org.assertj.core.api.Assertions.assertThat; import sta...
{"Test.Group:tesT:*", testArtifact().build(), true},
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keyserver/KeyServerClientSettingsTest.java
// Path: src/test/java/org/simplify4u/plugins/utils/ProxyUtil.java // public static Proxy makeMavenProxy(String proxyUser, String proxyPassword, String id, boolean active) { // Proxy proxy = new Proxy(); // proxy.setHost("localhost"); // proxy.setActive(active); // proxy.setNonProxyHosts("*"); // pr...
import org.mockito.testng.MockitoTestNGListener; import org.testng.annotations.Listeners; import org.testng.annotations.Test; import java.util.Arrays; import java.util.List; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.times; import static org.mo...
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/test/java/org/simplify4u/plugins/utils/ProxyUtil.java // public static Proxy makeMavenProxy(String proxyUser, String proxyPassword, String id, boolean active) { // Proxy proxy = new Proxy(); // proxy.setHost("localhost"); // proxy.setActive(active); // proxy.setNonProxyHosts("*"); // pr...
makeMavenProxy(null, null, "p1", true),
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/keysmap/KeysMap.java
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java // @Builder // @Value // public class KeyInfo { // // @NonNull // KeyFingerprint fingerprint; // // KeyFingerprint master; // // Collection<String> uids; // // int version; // int algorithm; // // int bits; // // Date d...
import org.apache.maven.artifact.Artifact; import org.codehaus.plexus.resource.ResourceManager; import org.codehaus.plexus.resource.loader.ResourceNotFoundException; import org.simplify4u.plugins.pgp.KeyInfo; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStre...
* @param artifact artifact to test * * @return key missing status */ public boolean isKeyMissing(Artifact artifact) { ArtifactData artifactData = new ArtifactData(artifact); return items.entrySet().stream() .filter(entry -> entry.getKey().isMatch(artifactData)) ...
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java // @Builder // @Value // public class KeyInfo { // // @NonNull // KeyFingerprint fingerprint; // // KeyFingerprint master; // // Collection<String> uids; // // int version; // int algorithm; // // int bits; // // Date d...
public boolean isValidKey(Artifact artifact, KeyInfo keyInfo) {
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keyserver/PGPKeysServerClientTest.java
// Path: src/test/java/org/simplify4u/plugins/utils/ProxyUtil.java // public static Proxy makeMavenProxy(String proxyUser, String proxyPassword, String id, boolean active) { // Proxy proxy = new Proxy(); // proxy.setHost("localhost"); // proxy.setActive(active); // proxy.setNonProxyHosts("*"); // pr...
import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.concurrent.atomic.AtomicInteger; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy;...
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/test/java/org/simplify4u/plugins/utils/ProxyUtil.java // public static Proxy makeMavenProxy(String proxyUser, String proxyPassword, String id, boolean active) { // Proxy proxy = new Proxy(); // proxy.setHost("localhost"); // proxy.setActive(active); // proxy.setNonProxyHosts("*"); // pr...
{makeMavenProxy("", "")},
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keyserver/PGPKeysServerClientTest.java
// Path: src/test/java/org/simplify4u/plugins/utils/ProxyUtil.java // public static Proxy makeMavenProxy(String proxyUser, String proxyPassword, String id, boolean active) { // Proxy proxy = new Proxy(); // proxy.setHost("localhost"); // proxy.setActive(active); // proxy.setNonProxyHosts("*"); // pr...
import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.concurrent.atomic.AtomicInteger; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy;...
} private void runProxyConfig(Proxy proxy) { when(mavenSession.getSettings()).thenReturn(settings); when(settings.getActiveProxy()).thenReturn(proxy); KeyServerClientSettings clientSettings = KeyServerClientSettings.builder() .mavenSession(mavenSession) ...
// Path: src/test/java/org/simplify4u/plugins/utils/ProxyUtil.java // public static Proxy makeMavenProxy(String proxyUser, String proxyPassword, String id, boolean active) { // Proxy proxy = new Proxy(); // proxy.setHost("localhost"); // proxy.setActive(active); // proxy.setNonProxyHosts("*"); // pr...
assertThatThrownBy(() -> pgpKeysServerClient.copyKeyToOutputStream(KeyId.from(0x0123456789ABCDEFL), null, null))
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/pgp/KeyFingerprint.java
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // @UtilityClass // public class HexUtils { // // /** // * Convert byte array of fingerprint to string of hex // * @param bytes fingerprint // * @return fingerprint as string // */ // public static String fingerprintToString(...
import com.fasterxml.jackson.annotation.JsonValue; import lombok.RequiredArgsConstructor; import lombok.Value; import org.simplify4u.plugins.utils.HexUtils;
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/main/java/org/simplify4u/plugins/utils/HexUtils.java // @UtilityClass // public class HexUtils { // // /** // * Convert byte array of fingerprint to string of hex // * @param bytes fingerprint // * @return fingerprint as string // */ // public static String fingerprintToString(...
fingerprint = HexUtils.stringToFingerprint(strFingerprint);
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/pgp/PublicKeyUtilsTest.java
// Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeyInfo aKeyInfo(String fingerprint) { // return KeyInfo.builder().fingerprint(new KeyFingerprint(fingerprint)).build(); // }
import java.io.IOException; import java.io.InputStream; import java.util.Optional; import static org.assertj.core.api.Assertions.assertThat; import static org.simplify4u.plugins.TestUtils.aKeyInfo; import org.bouncycastle.openpgp.PGPException; import org.bouncycastle.openpgp.PGPPublicKey; import org.bouncycastle.openpg...
.build(); assertThat(keyInfo.getMaster()).isNotNull(); assertThat(PublicKeyUtils.fingerprintForMaster(keyInfo)) .isEqualTo("0x58E79B6ABC762159DC0B1591164BD2247B936711"); } @Test public void userIdsWithSubKey() { PGPPublicKey key = SUB_KEY_ID.getKeyF...
// Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeyInfo aKeyInfo(String fingerprint) { // return KeyInfo.builder().fingerprint(new KeyFingerprint(fingerprint)).build(); // } // Path: src/test/java/org/simplify4u/plugins/pgp/PublicKeyUtilsTest.java import java.io.IOException; import j...
KeyInfo keyInfo = aKeyInfo("0x1234567890123456789012345678901234567890");
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keysmap/KeyItemFingerprintTest.java
// Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeyInfo aKeyInfo(String fingerprint) { // return KeyInfo.builder().fingerprint(new KeyFingerprint(fingerprint)).build(); // } // // Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java // @Builder // @Value // public class KeyInfo...
import static org.assertj.core.api.Assertions.assertThat; import static org.simplify4u.plugins.TestUtils.aKeyInfo; import org.simplify4u.plugins.pgp.KeyInfo; import org.testng.annotations.Test;
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeyInfo aKeyInfo(String fingerprint) { // return KeyInfo.builder().fingerprint(new KeyFingerprint(fingerprint)).build(); // } // // Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java // @Builder // @Value // public class KeyInfo...
KeyInfo keyInfo = aKeyInfo(FINGERPRINT_1);
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/keysmap/KeyItemFingerprintTest.java
// Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeyInfo aKeyInfo(String fingerprint) { // return KeyInfo.builder().fingerprint(new KeyFingerprint(fingerprint)).build(); // } // // Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java // @Builder // @Value // public class KeyInfo...
import static org.assertj.core.api.Assertions.assertThat; import static org.simplify4u.plugins.TestUtils.aKeyInfo; import org.simplify4u.plugins.pgp.KeyInfo; import org.testng.annotations.Test;
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/test/java/org/simplify4u/plugins/TestUtils.java // public static KeyInfo aKeyInfo(String fingerprint) { // return KeyInfo.builder().fingerprint(new KeyFingerprint(fingerprint)).build(); // } // // Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java // @Builder // @Value // public class KeyInfo...
KeyInfo keyInfo = aKeyInfo(FINGERPRINT_1);
s4u/pgpverify-maven-plugin
src/main/java/org/simplify4u/plugins/keysmap/KeyItem.java
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java // @Builder // @Value // public class KeyInfo { // // @NonNull // KeyFingerprint fingerprint; // // KeyFingerprint master; // // Collection<String> uids; // // int version; // int algorithm; // // int bits; // // Date d...
import org.simplify4u.plugins.pgp.KeyInfo;
/* * Copyright 2021 Slawomir Jaranowski * * 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 ag...
// Path: src/main/java/org/simplify4u/plugins/pgp/KeyInfo.java // @Builder // @Value // public class KeyInfo { // // @NonNull // KeyFingerprint fingerprint; // // KeyFingerprint master; // // Collection<String> uids; // // int version; // int algorithm; // // int bits; // // Date d...
default boolean isKeyMatch(KeyInfo keyInfo) {
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/ValidationChecksumTest.java
// Path: src/main/java/org/simplify4u/plugins/ValidationChecksum.java // static final class Builder { // // private static final String FILENAME_CHECKSUM_PRIOR_VALIDATION = "pgpverify-prior-validation-checksum"; // // private static final Logger LOG = LoggerFactory.getLogger(Builder.class); // // private...
import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.util.Comparator; import java.util.List; import static java.util.Arrays.asList; import static java.util.Collections.emptyList...
/* * Copyright 2020 Danny van Heumen * * 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 agree...
// Path: src/main/java/org/simplify4u/plugins/ValidationChecksum.java // static final class Builder { // // private static final String FILENAME_CHECKSUM_PRIOR_VALIDATION = "pgpverify-prior-validation-checksum"; // // private static final Logger LOG = LoggerFactory.getLogger(Builder.class); // // private...
new ValidationChecksum.Builder().destination(null).artifacts(emptyList()).build();
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/ArtifactResolverTest.java
// Path: src/main/java/org/simplify4u/plugins/ArtifactResolver.java // public static final class Configuration { // // final SkipFilter dependencyFilter; // final SkipFilter pluginFilter; // final boolean verifyPomFiles; // final boolean verifyPlugins; // final boolean verifyPluginDependencies; // ...
import java.util.Map; import java.util.Set; import static java.util.Collections.emptyList; import static java.util.Collections.singleton; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import stat...
when(project.getRemoteArtifactRepositories()).thenReturn(emptyList()); resolver = new ArtifactResolver(repositorySystem, session); } @Test public void testConstructArtifactResolverWithNull() { reset(session, project); assertThatCode(() -> new ArtifactResolver(null, null))...
// Path: src/main/java/org/simplify4u/plugins/ArtifactResolver.java // public static final class Configuration { // // final SkipFilter dependencyFilter; // final SkipFilter pluginFilter; // final boolean verifyPomFiles; // final boolean verifyPlugins; // final boolean verifyPluginDependencies; // ...
Configuration config = new Configuration(new CompositeSkipper(emptyList()),
s4u/pgpverify-maven-plugin
src/test/java/org/simplify4u/plugins/ArtifactResolverTest.java
// Path: src/main/java/org/simplify4u/plugins/ArtifactResolver.java // public static final class Configuration { // // final SkipFilter dependencyFilter; // final SkipFilter pluginFilter; // final boolean verifyPomFiles; // final boolean verifyPlugins; // final boolean verifyPluginDependencies; // ...
import java.util.Map; import java.util.Set; import static java.util.Collections.emptyList; import static java.util.Collections.singleton; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatCode; import stat...
when(project.getRemoteArtifactRepositories()).thenReturn(emptyList()); resolver = new ArtifactResolver(repositorySystem, session); } @Test public void testConstructArtifactResolverWithNull() { reset(session, project); assertThatCode(() -> new ArtifactResolver(null, null))...
// Path: src/main/java/org/simplify4u/plugins/ArtifactResolver.java // public static final class Configuration { // // final SkipFilter dependencyFilter; // final SkipFilter pluginFilter; // final boolean verifyPomFiles; // final boolean verifyPlugins; // final boolean verifyPluginDependencies; // ...
Configuration config = new Configuration(new CompositeSkipper(emptyList()),
xxv/Units
src/net/sourceforge/unitsinjava/Parser.java
// Path: src/net/sourceforge/unitsinjava/Source.java // public interface Source // { // boolean created(); // // int end(); // // char at(int p); // // String at(int p, int q); // // String where(int p); // }
import net.sourceforge.unitsinjava.Source;
//========================================================================= // // This file was generated by Mouse 1.3 at 2010-11-02 16:19:27 GMT\nfrom // grammar 'D:\Units\ units\grammar.peg'. // //========================================================================= package net.sourceforge.unitsinjava; pub...
// Path: src/net/sourceforge/unitsinjava/Source.java // public interface Source // { // boolean created(); // // int end(); // // char at(int p); // // String at(int p, int q); // // String where(int p); // } // Path: src/net/sourceforge/unitsinjava/Parser.java import net.sourceforge.unitsinjava.Source;...
public boolean parse(Source src)
xxv/Units
src/net/sourceforge/unitsinjava/ParserBase.java
// Path: src/net/sourceforge/unitsinjava/Source.java // public interface Source // { // boolean created(); // // int end(); // // char at(int p); // // String at(int p, int q); // // String where(int p); // }
import net.sourceforge.unitsinjava.Source; import java.util.Vector;
//========================================================================= // // Part of PEG parser generator Mouse. // // Copyright (C) 2009, 2010 by Roman R. Redziejowski (www.romanredz.se). // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance wi...
// Path: src/net/sourceforge/unitsinjava/Source.java // public interface Source // { // boolean created(); // // int end(); // // char at(int p); // // String at(int p, int q); // // String where(int p); // } // Path: src/net/sourceforge/unitsinjava/ParserBase.java import net.sourceforge.unitsinjava.Sou...
Source source; // Source of text to parse
interedition/collatex
collatex-core/src/test/java/eu/interedition/collatex/dekker/BeckettTest.java
// Path: collatex-core/src/main/java/eu/interedition/collatex/matching/Matches.java // public class Matches { // // public final Map<Token, List<VariantGraph.Vertex>> allMatches; // public final Set<Token> unmatchedInWitness; // public final Set<Token> ambiguousInWitness; // public final Set<Token> uni...
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import eu.interedition.collatex.*; import eu.interedition.collatex.matching.EqualityTokenComparator; import eu.interedition.collatex.matching.Matches; import eu.interedition.collatex.simple.SimpleToken; import eu.interedition.collat...
/* * Copyright (c) 2015 The Interedition Development Group. * * This file is part of CollateX. * * CollateX 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 you...
// Path: collatex-core/src/main/java/eu/interedition/collatex/matching/Matches.java // public class Matches { // // public final Map<Token, List<VariantGraph.Vertex>> allMatches; // public final Set<Token> unmatchedInWitness; // public final Set<Token> ambiguousInWitness; // public final Set<Token> uni...
final Map<Token, List<VariantGraph.Vertex>> matches = Matches.between(graph.vertices(), w[1], new EqualityTokenComparator()).allMatches;
interedition/collatex
collatex-core/src/test/java/eu/interedition/collatex/dekker/legacy/MatchTableLinkerTest.java
// Path: collatex-core/src/main/java/eu/interedition/collatex/matching/StrictEqualityTokenComparator.java // public class StrictEqualityTokenComparator implements Comparator<Token> { // // @Override // public int compare(Token base, Token witness) { // final String baseContent = ((SimpleToken) base).ge...
import java.util.logging.Level; import java.util.stream.Collectors; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import eu.interedition.collatex.*; import eu.interedition.collatex.dekker.DekkerAlgorithm; import eu.interedition.collatex.dekker.Match; import eu.interedition.coll...
assertTrue(tokensAsString.contains("C:4:'voer'")); assertTrue(tokensAsString.contains("C:5:'een'")); assertTrue(tokensAsString.contains("C:7:'grote'")); assertTrue(tokensAsString.contains("C:8:'stomer'")); } // String newLine = System.getProperty("line.separator"); @Test ...
// Path: collatex-core/src/main/java/eu/interedition/collatex/matching/StrictEqualityTokenComparator.java // public class StrictEqualityTokenComparator implements Comparator<Token> { // // @Override // public int compare(Token base, Token witness) { // final String baseContent = ((SimpleToken) base).ge...
collationAlgorithm = new DekkerAlgorithm(new StrictEqualityTokenComparator());
PhantomThief/more-lambdas-java
core-jdk9/src/test/java/com/github/phantomthief/util/MoreReflectionTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreReflection.java // @Nullable // public static StackTraceElement getCallerPlace() { // return getCallerPlace(MoreReflection.class); // }
import static com.github.phantomthief.util.MoreReflection.getCallerPlace; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import org.junit.jupiter.api.Test;
package com.github.phantomthief.util; /** * @author w.vela * Created on 2018-06-13. */ class MoreReflectionTest { @Test void testCaller() { StackTraceElement callerPlace = MyTest.test3(); assertNotNull(callerPlace); assertEquals("MoreReflectionTest.java", callerPlace.getFileName()...
// Path: core/src/main/java/com/github/phantomthief/util/MoreReflection.java // @Nullable // public static StackTraceElement getCallerPlace() { // return getCallerPlace(MoreReflection.class); // } // Path: core-jdk9/src/test/java/com/github/phantomthief/util/MoreReflectionTest.java import static com.github.phanto...
System.err.println(getCallerPlace());
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/concurrent/TimeoutListenableFuture.java
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
import static com.google.common.base.Preconditions.checkNotNull; import static org.slf4j.LoggerFactory.getLogger; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutExce...
package com.github.phantomthief.concurrent; /** * @author w.vela * Created on 16/5/31. */ public class TimeoutListenableFuture<V> extends ForwardingListenableFuture<V> { private static final Logger logger = getLogger(TimeoutListenableFuture.class); private final ListenableFuture<V> delegate;
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
private final List<ThrowableConsumer<TimeoutException, Exception>> timeoutListeners = new ArrayList<>();
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/concurrent/TimeoutListenableFuture.java
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
import static com.google.common.base.Preconditions.checkNotNull; import static org.slf4j.LoggerFactory.getLogger; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutExce...
package com.github.phantomthief.concurrent; /** * @author w.vela * Created on 16/5/31. */ public class TimeoutListenableFuture<V> extends ForwardingListenableFuture<V> { private static final Logger logger = getLogger(TimeoutListenableFuture.class); private final ListenableFuture<V> delegate; priv...
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
addTimeoutListener(@Nonnull ThrowableRunnable<Exception> listener) {
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/pool/impl/KeyAffinityTest.java
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.util.concurrent.MoreExecutors.shutdownAndAwaitTermination; import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly; import static java.util.concurrent.Executors.newFixedThreadPool; import stati...
ExecutorService executorService = newFixedThreadPool(50); Map<Integer, String> firstMapping = new ConcurrentHashMap<>(); for (int i = 0; i < 20; i++) { int j = i; executorService.execute(() -> { run(keyAffinity, j, v -> { firstMapping.p...
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
@Nonnull ThrowableFunction<V, T, X> func) throws X {
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/pool/impl/KeyAffinityTest.java
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.util.concurrent.MoreExecutors.shutdownAndAwaitTermination; import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly; import static java.util.concurrent.Executors.newFixedThreadPool; import stati...
sleepUninterruptibly(1, SECONDS); for (int i = 0; i < 1000; i++) { executorService.execute(() -> { int key = ThreadLocalRandom.current().nextInt(20); run(keyAffinity, key, v -> { String firstV = firstMapping.get(key); as...
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
@Nonnull ThrowableConsumer<V, X> func) throws X {
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/util/ThrowableUtilsTest.java
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableUtils.java // public static void changeThrowableMessage(Throwable throwable, Function<String, String> messageChangeFunc) { // changeThrowableMessage(throwable, messageChangeFunc.apply(throwable.getMessage())); // }
import static com.github.phantomthief.util.ThrowableUtils.changeThrowableMessage; import static com.google.common.base.Preconditions.checkArgument; import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory;
package com.github.phantomthief.util; /** * @author w.vela * Created on 2019-06-18. */ class ThrowableUtilsTest { private static final Logger logger = LoggerFactory.getLogger(ThrowableUtilsTest.class); @Test void test() { try { checkArgument(false, "myTest"); } catch (Ill...
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableUtils.java // public static void changeThrowableMessage(Throwable throwable, Function<String, String> messageChangeFunc) { // changeThrowableMessage(throwable, messageChangeFunc.apply(throwable.getMessage())); // } // Path: core/src/test/java/com/g...
changeThrowableMessage(e, it -> it + "!!!");
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/concurrent/MoreFuturesDynamicTest.java
// Path: core/src/main/java/com/github/phantomthief/concurrent/MoreFutures.java // public static Future<?> scheduleWithDynamicDelay(@Nonnull ScheduledExecutorService executor, // @Nullable Duration initDelay, @Nonnull Scheduled task) { // checkNotNull(executor); // checkNotNull(task); // AtomicBoole...
import static com.github.phantomthief.concurrent.MoreFutures.scheduleWithDynamicDelay; import static com.google.common.util.concurrent.MoreExecutors.shutdownAndAwaitTermination; import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly; import static java.time.Duration.ofSeconds; import stat...
package com.github.phantomthief.concurrent; /** * @author w.vela * Created on 2019-11-26. */ class MoreFuturesDynamicTest { private static final Logger logger = LoggerFactory.getLogger(MoreFuturesDynamicTest.class); @Test void test() { ScheduledExecutorService scheduled = newSingleThreadSch...
// Path: core/src/main/java/com/github/phantomthief/concurrent/MoreFutures.java // public static Future<?> scheduleWithDynamicDelay(@Nonnull ScheduledExecutorService executor, // @Nullable Duration initDelay, @Nonnull Scheduled task) { // checkNotNull(executor); // checkNotNull(task); // AtomicBoole...
Future<?> future = scheduleWithDynamicDelay(scheduled, () -> {
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/util/MorePreconditionsTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MorePreconditions.java // public static <X extends Throwable> void checkOrThrow(boolean expression, Supplier<X> exception) throws X { // if (!expression) { // throw exception.get(); // } // }
import static com.github.phantomthief.util.MorePreconditions.checkOrThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.IOException; import org.junit.jupiter.api.Test;
package com.github.phantomthief.util; /** * @author w.vela * Created on 2020-02-26. */ class MorePreconditionsTest { @Test void test() throws IOException {
// Path: core/src/main/java/com/github/phantomthief/util/MorePreconditions.java // public static <X extends Throwable> void checkOrThrow(boolean expression, Supplier<X> exception) throws X { // if (!expression) { // throw exception.get(); // } // } // Path: core/src/test/java/com/github/phantomthief/u...
checkOrThrow(true, IOException::new, "test");
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/test/MoreStreamsTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreStreams.java // public class MoreStreams { // // /** // * 工具类,禁止实例化成对象 // */ // private MoreStreams() { // throw new UnsupportedOperationException(); // } // // /** // * 创建一个类型为long的Stream,返回从开始到结束一个闭区间内的整数 // * /...
import java.util.stream.Stream; import org.junit.jupiter.api.Test; import com.github.phantomthief.util.MoreStreams;
package com.github.phantomthief.test; /** * @author w.vela */ class MoreStreamsTest { @Test void testRange() {
// Path: core/src/main/java/com/github/phantomthief/util/MoreStreams.java // public class MoreStreams { // // /** // * 工具类,禁止实例化成对象 // */ // private MoreStreams() { // throw new UnsupportedOperationException(); // } // // /** // * 创建一个类型为long的Stream,返回从开始到结束一个闭区间内的整数 // * /...
MoreStreams.longRangeClosed(10, 15).forEach(System.out::println);
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/concurrent/MoreFutures.java
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly; import static java.lang.System.nanoTime; import static java.util.concurrent.TimeUnit.MILLISECONDS; impor...
* // don't try/catch the exception it throws. * Map<Future<User>, User> success = tryWait(list, 1, SECONDS); * }</pre> * * @param futures 要获取值的多个{@link Future} * @param timeout 超时时间 * @param unit 超时时间单位 * @throws TryWaitFutureUncheckedException 当并非所有的{@link Future}都成功返回时,将会抛出此异...
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
@Nonnull Duration duration, @Nonnull ThrowableFunction<K, Future<V>, X> asyncFunc)
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/concurrent/MoreFutures.java
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly; import static java.lang.System.nanoTime; import static java.util.concurrent.TimeUnit.MILLISECONDS; impor...
*/ public static Future<?> scheduleWithDynamicDelay(@Nonnull ScheduledExecutorService executor, @Nullable Duration initDelay, @Nonnull Scheduled task) { checkNotNull(executor); checkNotNull(task); AtomicBoolean canceled = new AtomicBoolean(false); AbstractFuture<?> f...
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
@Nonnull ThrowableRunnable<Throwable> task) {
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/concurrent/MoreFutures.java
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly; import static java.lang.System.nanoTime; import static java.util.concurrent.TimeUnit.MILLISECONDS; impor...
} return delay.get(); }); } /** * 用于替换 {@link Futures#transform(ListenableFuture, com.google.common.base.Function, Executor)} * <p> * 主要提供两个额外的功能: * 1. API使用jdk8 * 2. 提供了 {@link TimeoutListenableFuture} 的支持(保持Listener不会丢) * * @param input 输入的Fu...
// Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // void accept(T t) throws X; // // default ThrowableConsumer<T, X> andThen(ThrowableConsumer<? super T, X> after) { // requireNonN...
for (ThrowableConsumer<TimeoutException, Exception> timeoutListener : ((TimeoutListenableFuture<I>) input)
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/pool/impl/DynamicCapacityLinkedBlockingQueue.java
// Path: core/src/main/java/com/github/phantomthief/util/SimpleRateLimiter.java // @ThreadSafe // public class SimpleRateLimiter { // // private final LongAdder skip = new LongAdder(); // // /** // * 多少ns允许一次请求 // */ // private long allowTimesPerNanos; // private volatile long lastAcquiredNa...
import java.util.Collection; import java.util.Iterator; import java.util.Spliterator; import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.function.IntSupplier; import java.util.function.Predicate; import com.github.phantomthief.util.Simpl...
package com.github.phantomthief.pool.impl; /** * 备注,本类主要是用于给 * {@link com.github.phantomthief.pool.KeyAffinityExecutor#newSerializingExecutor(IntSupplier, IntSupplier, String)} * 提供支持的,并不推荐大家直接使用,未来也可能会随时调整实现和行为 * * @author w.vela * Created on 2020-08-19. */ public class DynamicCapacityLinkedBlockingQueue<E> ...
// Path: core/src/main/java/com/github/phantomthief/util/SimpleRateLimiter.java // @ThreadSafe // public class SimpleRateLimiter { // // private final LongAdder skip = new LongAdder(); // // /** // * 多少ns允许一次请求 // */ // private long allowTimesPerNanos; // private volatile long lastAcquiredNa...
private final SimpleRateLimiter rateLimiter;
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/test/MoreRunnablesTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreRunnables.java // public final class MoreRunnables { // // /** // * 将给定的{@link Runnable}包装为只执行一次的对象,通常可以用来做首次运行时初始化的工作 // * // * @param runnable 传入的{@link Runnable} // * @return 经过包装,只运行一次的{@link Runnable} // */ // public sta...
import com.github.phantomthief.util.MoreRunnables; import static org.junit.jupiter.api.Assertions.fail; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.jupiter.api.Test;
package com.github.phantomthief.test; /** * @author w.vela * Created on 16/3/14. */ class MoreRunnablesTest { @Test void test() { AtomicBoolean runned = new AtomicBoolean(false);
// Path: core/src/main/java/com/github/phantomthief/util/MoreRunnables.java // public final class MoreRunnables { // // /** // * 将给定的{@link Runnable}包装为只执行一次的对象,通常可以用来做首次运行时初始化的工作 // * // * @param runnable 传入的{@link Runnable} // * @return 经过包装,只运行一次的{@link Runnable} // */ // public sta...
Runnable runOnce = MoreRunnables.runOnce(() -> {
PhantomThief/more-lambdas-java
core-jdk9/src/test/java/com/github/phantomthief/util/JdkProviderTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreReflection.java // @Nullable // public static StackTraceElement getCallerPlace() { // return getCallerPlace(MoreReflection.class); // }
import static com.github.phantomthief.util.MoreReflection.getCallerPlace; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import org.junit.jupiter.api.Test;
callerPlace = MyTest2.test911(); assertNotNull(callerPlace); assertEquals("JdkProviderTest.java", callerPlace.getFileName()); } @Test void testReflection8() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Method test41 = MyTest2.class.getDec...
// Path: core/src/main/java/com/github/phantomthief/util/MoreReflection.java // @Nullable // public static StackTraceElement getCallerPlace() { // return getCallerPlace(MoreReflection.class); // } // Path: core-jdk9/src/test/java/com/github/phantomthief/util/JdkProviderTest.java import static com.github.phantomth...
System.err.println(getCallerPlace());
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/util/RateLogger.java
// Path: core/src/main/java/com/github/phantomthief/tuple/Tuple.java // public static <A, B> TwoTuple<A, B> tuple(final A a, final B b) { // return new TwoTuple<>(a, b); // } // // Path: core/src/main/java/com/github/phantomthief/tuple/ThreeTuple.java // public class ThreeTuple<A, B, C> extends TwoTuple<A, B> { //...
import static com.github.phantomthief.tuple.Tuple.tuple; import static org.slf4j.spi.LocationAwareLogger.DEBUG_INT; import static org.slf4j.spi.LocationAwareLogger.ERROR_INT; import static org.slf4j.spi.LocationAwareLogger.INFO_INT; import static org.slf4j.spi.LocationAwareLogger.TRACE_INT; import static org.slf4j.spi....
package com.github.phantomthief.util; /** * 使用 {@link SimpleRateLimiter} 来控制打 log 输出的频率,避免出现 log flood 占用过高的 CPU <p> * 对于需要用一个 logger 打不同类型的日志,又不希望不同日志输出频率互相干扰(比如高频日志把低频日志淹没)<p> * 可以使用 {@link #perMessageRateLogger(Logger)} 方式构建 logger,这时候,不同日志的区分方式是以 log.info(msg, args...);<p> * 中第一个参数 msg 来区分,相同的 msg 会被认为是相同...
// Path: core/src/main/java/com/github/phantomthief/tuple/Tuple.java // public static <A, B> TwoTuple<A, B> tuple(final A a, final B b) { // return new TwoTuple<>(a, b); // } // // Path: core/src/main/java/com/github/phantomthief/tuple/ThreeTuple.java // public class ThreeTuple<A, B, C> extends TwoTuple<A, B> { //...
private static final ConcurrentMap<ThreeTuple<String, Double, Boolean>, RateLogger> CACHE = new ConcurrentHashMap<>();
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/util/RateLogger.java
// Path: core/src/main/java/com/github/phantomthief/tuple/Tuple.java // public static <A, B> TwoTuple<A, B> tuple(final A a, final B b) { // return new TwoTuple<>(a, b); // } // // Path: core/src/main/java/com/github/phantomthief/tuple/ThreeTuple.java // public class ThreeTuple<A, B, C> extends TwoTuple<A, B> { //...
import static com.github.phantomthief.tuple.Tuple.tuple; import static org.slf4j.spi.LocationAwareLogger.DEBUG_INT; import static org.slf4j.spi.LocationAwareLogger.ERROR_INT; import static org.slf4j.spi.LocationAwareLogger.INFO_INT; import static org.slf4j.spi.LocationAwareLogger.TRACE_INT; import static org.slf4j.spi....
/** * 工厂方法 * * @param logger 要封装的logger实例 * @param permitsPer 打log的每秒允许个数,例如传入0.2,就意味着五秒打一条log */ public static RateLogger rateLogger(Logger logger, double permitsPer) { return rateLogger(logger, permitsPer, false); } /** * 工厂方法,和 {@link #rateLogger} 的区别是,会按照不同的 m...
// Path: core/src/main/java/com/github/phantomthief/tuple/Tuple.java // public static <A, B> TwoTuple<A, B> tuple(final A a, final B b) { // return new TwoTuple<>(a, b); // } // // Path: core/src/main/java/com/github/phantomthief/tuple/ThreeTuple.java // public class ThreeTuple<A, B, C> extends TwoTuple<A, B> { //...
ThreeTuple<String, Double, Boolean> key = tuple(name, permitsPer, perFormatString);
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/test/ToStringHelperTest.java
// Path: core/src/main/java/com/github/phantomthief/util/ToStringHelper.java // public class ToStringHelper { // // public static <T> T wrapToString(Class<T> interfaceType, T obj, // Function<T, String> toStringSupplier) { // return newProxy(interfaceType, (proxy, method, args) -> { // ...
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.List; import java.util.Objects; import org.junit.jupiter.api.Test; import com.github.phantomthief.util.ToStringHelper;
package com.github.phantomthief.test; /** * @author w.vela * Created on 16/5/7. */ class ToStringHelperTest { @Test void test() { List<Integer> list = Arrays.asList(1, 2, 3); String ori = list.toString();
// Path: core/src/main/java/com/github/phantomthief/util/ToStringHelper.java // public class ToStringHelper { // // public static <T> T wrapToString(Class<T> interfaceType, T obj, // Function<T, String> toStringSupplier) { // return newProxy(interfaceType, (proxy, method, args) -> { // ...
List<Integer> list2 = ToStringHelper.wrapToString(List.class, list, i -> i + "!!!!");
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/pool/impl/KeyAffinityBuilder.java
// Path: core/src/main/java/com/github/phantomthief/pool/KeyAffinityExecutorUtils.java // public static final int RANDOM_THRESHOLD = 20; // // Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // ...
import static com.github.phantomthief.pool.KeyAffinityExecutorUtils.RANDOM_THRESHOLD; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import java.util.function.BooleanSupplier; import java.util.function.IntPredicate; import java.util.fun...
package com.github.phantomthief.pool.impl; /** * @author w.vela * Created on 2018-02-09. */ @NotThreadSafe class KeyAffinityBuilder<V> { private Supplier<V> factory; private IntSupplier count;
// Path: core/src/main/java/com/github/phantomthief/pool/KeyAffinityExecutorUtils.java // public static final int RANDOM_THRESHOLD = 20; // // Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // ...
private ThrowableConsumer<V, Exception> depose;
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/pool/impl/KeyAffinityBuilder.java
// Path: core/src/main/java/com/github/phantomthief/pool/KeyAffinityExecutorUtils.java // public static final int RANDOM_THRESHOLD = 20; // // Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // ...
import static com.github.phantomthief.pool.KeyAffinityExecutorUtils.RANDOM_THRESHOLD; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; import java.util.function.BooleanSupplier; import java.util.function.IntPredicate; import java.util.fun...
package com.github.phantomthief.pool.impl; /** * @author w.vela * Created on 2018-02-09. */ @NotThreadSafe class KeyAffinityBuilder<V> { private Supplier<V> factory; private IntSupplier count; private ThrowableConsumer<V, Exception> depose; private IntPredicate usingRandom; private BooleanS...
// Path: core/src/main/java/com/github/phantomthief/pool/KeyAffinityExecutorUtils.java // public static final int RANDOM_THRESHOLD = 20; // // Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public interface ThrowableConsumer<T, X extends Throwable> { // // ...
usingRandom = it -> it > RANDOM_THRESHOLD;
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/util/MoreReflectionTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreReflection.java // @Nullable // public static StackTraceElement getCallerPlace() { // return getCallerPlace(MoreReflection.class); // }
import static com.github.phantomthief.util.MoreReflection.getCallerPlace; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import org.junit.jupiter.api.Test;
package com.github.phantomthief.util; /** * @author w.vela * Created on 2018-06-13. */ class MoreReflectionTest { @Test void test() { MyTest.test(); MyTest.test2(); } @Test void testKotlinCaller() { KotlinCaller.test1(); } @Test void testCaller() { ...
// Path: core/src/main/java/com/github/phantomthief/util/MoreReflection.java // @Nullable // public static StackTraceElement getCallerPlace() { // return getCallerPlace(MoreReflection.class); // } // Path: core/src/test/java/com/github/phantomthief/util/MoreReflectionTest.java import static com.github.phantomthie...
System.err.println(getCallerPlace());
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/util/MoreIterables.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreStreams.java // public static <T> Stream<T> toStream(Iterator<T> iterator) { // checkNotNull(iterator); // return stream(spliteratorUnknownSize(iterator, (NONNULL | IMMUTABLE | ORDERED)), false); // }
import static com.github.phantomthief.util.MoreStreams.toStream; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Iterables.partition; import static java.lang.Math.max; import static java.lang.Math.min; import static java.util.Collections.singleton; import static...
package com.github.phantomthief.util; /** * MoreIterables增强工具集合 * <p>迭代器快捷工具,用于快速获取批次数列</p> * * @author w.vela */ public final class MoreIterables { /** * 工具类,禁止实例化成对象 */ private MoreIterables() { throw new UnsupportedOperationException(); } /** * 取得一个闭区间的long类型的数列,并按批次...
// Path: core/src/main/java/com/github/phantomthief/util/MoreStreams.java // public static <T> Stream<T> toStream(Iterator<T> iterator) { // checkNotNull(iterator); // return stream(spliteratorUnknownSize(iterator, (NONNULL | IMMUTABLE | ORDERED)), false); // } // Path: core/src/main/java/com/github/phantomth...
return toStream(batchClosedRange(from, to, batch));
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/pool/impl/DynamicCapacityLinkedBlockingQueueTest.java
// Path: core/src/main/java/com/github/phantomthief/pool/impl/DynamicCapacityLinkedBlockingQueue.java // public static <T> BlockingQueue<T> lazyDynamicCapacityLinkedBlockingQueue(IntSupplier capacity) { // return new LazyBlockingQueue<>(() -> new DynamicCapacityLinkedBlockingQueue<>(capacity)); // }
import static com.github.phantomthief.pool.impl.DynamicCapacityLinkedBlockingQueue.lazyDynamicCapacityLinkedBlockingQueue; import static com.google.common.util.concurrent.SimpleTimeLimiter.create; import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly; import static java.util.concurrent.E...
package com.github.phantomthief.pool.impl; /** * @author w.vela * Created on 2020-08-20. */ class DynamicCapacityLinkedBlockingQueueTest { private static final Logger logger = LoggerFactory.getLogger(DynamicCapacityLinkedBlockingQueueTest.class); @Test void test() throws InterruptedException { ...
// Path: core/src/main/java/com/github/phantomthief/pool/impl/DynamicCapacityLinkedBlockingQueue.java // public static <T> BlockingQueue<T> lazyDynamicCapacityLinkedBlockingQueue(IntSupplier capacity) { // return new LazyBlockingQueue<>(() -> new DynamicCapacityLinkedBlockingQueue<>(capacity)); // } // Path: core...
BlockingQueue<Object> queue = lazyDynamicCapacityLinkedBlockingQueue(() -> {
PhantomThief/more-lambdas-java
core-jdk8-test/src/test/java/com/github/phantomthief/util/MoreReflectionJdk8CompatibilityTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreReflection.java // static StackTraceProvider getStackTraceProvider() { // return STACK_TRACE_PROVIDER; // }
import static com.github.phantomthief.util.MoreReflection.getStackTraceProvider; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertSame; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test;
package com.github.phantomthief.util; /** * @author w.vela * Created on 2019-08-01. */ class MoreReflectionJdk8CompatibilityTest { /** * 需要使用 JDK8 来测试 */ @Disabled @Test void test() {
// Path: core/src/main/java/com/github/phantomthief/util/MoreReflection.java // static StackTraceProvider getStackTraceProvider() { // return STACK_TRACE_PROVIDER; // } // Path: core-jdk8-test/src/test/java/com/github/phantomthief/util/MoreReflectionJdk8CompatibilityTest.java import static com.github.phantomthief...
StackTraceProvider stackTraceProvider = getStackTraceProvider();
PhantomThief/more-lambdas-java
core-jdk9/src/test/java/com/github/phantomthief/util/CallerTrackBenchmark.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreReflection.java // @Nullable // public static StackTraceElement getCallerPlace() { // return getCallerPlace(MoreReflection.class); // }
import static com.github.phantomthief.util.MoreReflection.getCallerPlace; import java.util.concurrent.TimeUnit; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; import org.openjdk.jmh....
package com.github.phantomthief.util; /** * 性能指标: * * Benchmark Mode Cnt Score Error Units * CallerTrackBenchmark.testJdk8 thrpt 5 158153.109 ± 59700.454 ops/s * CallerTrackBenchmark.testJdk9 thrpt 5 373640.233 ± 178347.303 ops/s * * @author w.vela * Created...
// Path: core/src/main/java/com/github/phantomthief/util/MoreReflection.java // @Nullable // public static StackTraceElement getCallerPlace() { // return getCallerPlace(MoreReflection.class); // } // Path: core-jdk9/src/test/java/com/github/phantomthief/util/CallerTrackBenchmark.java import static com.github.phan...
System.err.println(getCallerPlace());
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/util/MoreCollectorsTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreCollectors.java // public static <T, K> Collector<T, ?, Map<K, List<T>>> groupingByAllowNullKey( // Function<? super T, ? extends K> classifier) { // return groupingByAllowNullKey(classifier, toList()); // }
import static com.github.phantomthief.util.MoreCollectors.groupingByAllowNullKey; import static java.util.function.Function.identity; import static java.util.stream.Collectors.groupingBy; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toMap; import static org.junit.jupiter.a...
package com.github.phantomthief.util; /** * MoreCollectorsTest * <p> * Write the code. Change the world. * * @author trang * @date 2019-07-31 */ class MoreCollectorsTest { /** * toMap() 本身支持 null key,但不支持 null value */ @Test void toMapTest() { Map<Integer, TestEnum1> map = ...
// Path: core/src/main/java/com/github/phantomthief/util/MoreCollectors.java // public static <T, K> Collector<T, ?, Map<K, List<T>>> groupingByAllowNullKey( // Function<? super T, ? extends K> classifier) { // return groupingByAllowNullKey(classifier, toList()); // } // Path: core/src/test/java/com/githu...
Stream.of(TestEnum2.values()).collect(groupingByAllowNullKey(TestEnum2::getValue));
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/pool/impl/KeyAffinityImpl.java
// Path: core/src/main/java/com/github/phantomthief/pool/KeyAffinity.java // @Deprecated // public interface KeyAffinity<K, V> extends AutoCloseable, Iterable<V> { // // boolean inited(); // } // // Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public inte...
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.collect.Iterators.transform; import static com.google.common.util.concurrent.Uninterruptibles.sleepUninterruptibly; import static java.util.Comparator.comparingInt; import static java.util.concurrent.TimeUnit.MILLISECONDS; ...
package com.github.phantomthief.pool.impl; /** * @author w.vela * Created on 2018-02-08. */ class KeyAffinityImpl<K, V> implements KeyAffinity<K, V> { private static final Logger logger = LoggerFactory.getLogger(KeyAffinityImpl.class); private static long sleepBeforeClose = SECONDS.toMillis(5); p...
// Path: core/src/main/java/com/github/phantomthief/pool/KeyAffinity.java // @Deprecated // public interface KeyAffinity<K, V> extends AutoCloseable, Iterable<V> { // // boolean inited(); // } // // Path: core/src/main/java/com/github/phantomthief/util/ThrowableConsumer.java // @FunctionalInterface // public inte...
private final ThrowableConsumer<V, Exception> deposeFunc;
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/test/MoreFunctionsTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
import static com.github.phantomthief.util.MoreFunctions.catching; import static com.github.phantomthief.util.MoreFunctions.consumerKv; import static com.github.phantomthief.util.MoreFunctions.filterKv; import static com.github.phantomthief.util.MoreFunctions.mapKv; import static com.github.phantomthief.util.MoreFuncti...
package com.github.phantomthief.test; /** * @author w.vela */ class MoreFunctionsTest { @Test void testTrying() {
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
assertNull(catching(i -> function(i, Exception::new), 1));
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/test/MoreFunctionsTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
import static com.github.phantomthief.util.MoreFunctions.catching; import static com.github.phantomthief.util.MoreFunctions.consumerKv; import static com.github.phantomthief.util.MoreFunctions.filterKv; import static com.github.phantomthief.util.MoreFunctions.mapKv; import static com.github.phantomthief.util.MoreFuncti...
package com.github.phantomthief.test; /** * @author w.vela */ class MoreFunctionsTest { @Test void testTrying() { assertNull(catching(i -> function(i, Exception::new), 1)); assertNull(catching(i -> function(i, IllegalArgumentException::new), 1)); assertEquals("1", catching(i -> f...
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
assertThrows(IllegalArgumentException.class, () -> throwing(() -> {
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/test/MoreFunctionsTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
import static com.github.phantomthief.util.MoreFunctions.catching; import static com.github.phantomthief.util.MoreFunctions.consumerKv; import static com.github.phantomthief.util.MoreFunctions.filterKv; import static com.github.phantomthief.util.MoreFunctions.mapKv; import static com.github.phantomthief.util.MoreFuncti...
package com.github.phantomthief.test; /** * @author w.vela */ class MoreFunctionsTest { @Test void testTrying() { assertNull(catching(i -> function(i, Exception::new), 1)); assertNull(catching(i -> function(i, IllegalArgumentException::new), 1)); assertEquals("1", catching(i -> f...
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
runParallel(new ForkJoinPool(10), () -> list.stream().parallel()
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/test/MoreFunctionsTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
import static com.github.phantomthief.util.MoreFunctions.catching; import static com.github.phantomthief.util.MoreFunctions.consumerKv; import static com.github.phantomthief.util.MoreFunctions.filterKv; import static com.github.phantomthief.util.MoreFunctions.mapKv; import static com.github.phantomthief.util.MoreFuncti...
@Test void testThrowing() { assertThrows(IllegalArgumentException.class, () -> throwing(() -> { throw new IllegalArgumentException(); })); assertTrue(assertThrows(RuntimeException.class, () -> throwing(() -> { throw new IOException(); })).getCause() insta...
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
runWithThreadName(it -> it + mySuffix, () -> {
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/test/MoreFunctionsTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
import static com.github.phantomthief.util.MoreFunctions.catching; import static com.github.phantomthief.util.MoreFunctions.consumerKv; import static com.github.phantomthief.util.MoreFunctions.filterKv; import static com.github.phantomthief.util.MoreFunctions.mapKv; import static com.github.phantomthief.util.MoreFuncti...
} private <X extends Throwable> String function(int i, Supplier<X> exception) throws X { if (exception != null) { X x = exception.get(); throw x; } else { return i + ""; } } @Test void testParallel() { List<Integer> list = Stream....
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
.filter(filterKv((k, v) -> true))
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/test/MoreFunctionsTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
import static com.github.phantomthief.util.MoreFunctions.catching; import static com.github.phantomthief.util.MoreFunctions.consumerKv; import static com.github.phantomthief.util.MoreFunctions.filterKv; import static com.github.phantomthief.util.MoreFunctions.mapKv; import static com.github.phantomthief.util.MoreFuncti...
private <X extends Throwable> String function(int i, Supplier<X> exception) throws X { if (exception != null) { X x = exception.get(); throw x; } else { return i + ""; } } @Test void testParallel() { List<Integer> list = Stream.iterat...
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
.forEach(consumerKv((k, v) -> System.out.println(k + "==>" + v)));
PhantomThief/more-lambdas-java
core/src/test/java/com/github/phantomthief/test/MoreFunctionsTest.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
import static com.github.phantomthief.util.MoreFunctions.catching; import static com.github.phantomthief.util.MoreFunctions.consumerKv; import static com.github.phantomthief.util.MoreFunctions.filterKv; import static com.github.phantomthief.util.MoreFunctions.mapKv; import static com.github.phantomthief.util.MoreFuncti...
if (exception != null) { X x = exception.get(); throw x; } else { return i + ""; } } @Test void testParallel() { List<Integer> list = Stream.iterate(1, i -> i + 1).limit(10000).collect(toList()); runParallel(new ForkJoinPool(10), (...
// Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <R> R catching(Callable<R> callable) { // return catching(callable, e -> logger.error(FAIL_SAFE_MARK, e)); // } // // Path: core/src/main/java/com/github/phantomthief/util/MoreFunctions.java // public static <K, V> Consume...
.map(mapKv((k, v) -> v))
PhantomThief/more-lambdas-java
core-jdk9/src/main/java/com/github/phantomthief/util/StackTraceProviderJdk9.java
// Path: core/src/main/java/com/github/phantomthief/util/StackTraceProviderJdk8.java // static final String[] REFLECTION_PREFIXES = {"sun.reflect.", "java.lang.reflect.", "jdk.internal.reflect."};
import static com.github.phantomthief.util.StackTraceProviderJdk8.REFLECTION_PREFIXES; import static java.lang.StackWalker.Option.RETAIN_CLASS_REFERENCE; import java.lang.StackWalker.StackFrame; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Stream; import javax.annotat...
return false; } if (afterSelf) { if (deprecatedClass == null) { deprecatedClass = declaringClass; } } ...
// Path: core/src/main/java/com/github/phantomthief/util/StackTraceProviderJdk8.java // static final String[] REFLECTION_PREFIXES = {"sun.reflect.", "java.lang.reflect.", "jdk.internal.reflect."}; // Path: core-jdk9/src/main/java/com/github/phantomthief/util/StackTraceProviderJdk9.java import static com.github.phanto...
return StringUtils.startsWithAny(className, REFLECTION_PREFIXES);
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/concurrent/TryWaitResult.java
// Path: core/src/main/java/com/github/phantomthief/util/MoreSuppliers.java // public static <T> CloseableSupplier<T> lazy(Supplier<T> delegate) { // return lazy(delegate, true); // }
import static com.github.phantomthief.util.MoreSuppliers.lazy; import static com.google.common.base.MoreObjects.toStringHelper; import static java.util.stream.Collectors.toMap; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.concurrent.CancellationException; import java.util...
package com.github.phantomthief.concurrent; /** * @author w.vela * Created on 2018-06-25. */ class TryWaitResult<K, V> { private final Map<Future<? extends V>, V> success; private final Map<Future<? extends V>, Throwable> failed; private final Map<Future<? extends V>, TimeoutException> timeout; ...
// Path: core/src/main/java/com/github/phantomthief/util/MoreSuppliers.java // public static <T> CloseableSupplier<T> lazy(Supplier<T> delegate) { // return lazy(delegate, true); // } // Path: core/src/main/java/com/github/phantomthief/concurrent/TryWaitResult.java import static com.github.phantomthief.util.MoreS...
successMap = lazy(() -> transfer(this.success, this.futureMap));
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/util/NameServiceUtils.java
// Path: core/src/main/java/com/github/phantomthief/tuple/Tuple.java // public final class Tuple { // // private Tuple() { // throw new UnsupportedOperationException(); // } // // public static <A, B> TwoTuple<A, B> tuple(final A a, final B b) { // return new TwoTuple<>(a, b); // } // ...
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Throwables.throwIfUnchecked; import static com.google.common.reflect.Reflection.newProxy; import static org.apache.commons.lang3.reflect.FieldUtils.readDeclaredStaticField; import static org.apache.commons.lang3.reflect....
package com.github.phantomthief.util; /** * @author w.vela * Created on 2019-12-25. */ public class NameServiceUtils { private static final byte[] LOCAL_HOST = {127, 0, 0, 1}; private static <T, R> R doInvoke(Object object, String method, T it) throws UnknownHostException { try { ...
// Path: core/src/main/java/com/github/phantomthief/tuple/Tuple.java // public final class Tuple { // // private Tuple() { // throw new UnsupportedOperationException(); // } // // public static <A, B> TwoTuple<A, B> tuple(final A a, final B b) { // return new TwoTuple<>(a, b); // } // ...
private static TwoTuple<Object, List<Object>> unwrapList(Object object) {
PhantomThief/more-lambdas-java
core/src/main/java/com/github/phantomthief/util/NameServiceUtils.java
// Path: core/src/main/java/com/github/phantomthief/tuple/Tuple.java // public final class Tuple { // // private Tuple() { // throw new UnsupportedOperationException(); // } // // public static <A, B> TwoTuple<A, B> tuple(final A a, final B b) { // return new TwoTuple<>(a, b); // } // ...
import static com.google.common.base.Preconditions.checkState; import static com.google.common.base.Throwables.throwIfUnchecked; import static com.google.common.reflect.Reflection.newProxy; import static org.apache.commons.lang3.reflect.FieldUtils.readDeclaredStaticField; import static org.apache.commons.lang3.reflect....
package com.github.phantomthief.util; /** * @author w.vela * Created on 2019-12-25. */ public class NameServiceUtils { private static final byte[] LOCAL_HOST = {127, 0, 0, 1}; private static <T, R> R doInvoke(Object object, String method, T it) throws UnknownHostException { try { ...
// Path: core/src/main/java/com/github/phantomthief/tuple/Tuple.java // public final class Tuple { // // private Tuple() { // throw new UnsupportedOperationException(); // } // // public static <A, B> TwoTuple<A, B> tuple(final A a, final B b) { // return new TwoTuple<>(a, b); // } // ...
return Tuple.tuple(list.get(0), list);