Skip to content

Commit

Permalink
Merge a8c1cef into f2049dd
Browse files Browse the repository at this point in the history
  • Loading branch information
cardil committed Mar 30, 2016
2 parents f2049dd + a8c1cef commit 9527517
Show file tree
Hide file tree
Showing 19 changed files with 520 additions and 307 deletions.
30 changes: 24 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
language: java
sudo: false
script: mvn clean install -P '!sonar,ci' --fail-at-end
script: mvn clean install --fail-at-end
notifications:
email:
on_failure: true
jdk:
- openjdk6
- openjdk7
- oraclejdk7
- oraclejdk8
matrix:
include:
- jdk: openjdk6
env: JACOCO=true
- jdk: openjdk7
env: JACOCO=true COVERALLS=true
- jdk: oraclejdk7
env: JACOCO=true
- jdk: oraclejdk8
env: JACOCO=true
- jdk: openjdk7
env: JACOCO=true GDMSESSION=sonar
- jdk: openjdk7
env: JACOCO=true SONAR=publish
script: mvn clean install sonar:sonar --fail-at-end
- jdk: openjdk6
env: JACOCO=false
- jdk: openjdk7
env: JACOCO=false
- jdk: oraclejdk7
env: JACOCO=false
- jdk: oraclejdk8
env: JACOCO=false
19 changes: 14 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@
<sonar.java.source>${java.source.version}</sonar.java.source>
<maven.compiler.source>1.${java.source.version}</maven.compiler.source>
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
<jacoco.version>0.7.6.201602180812</jacoco.version>

<skipTests/>
<coveralls.skip>${skipTests}</coveralls.skip>
<sonar.skip>${skipTests}</sonar.skip>
<failsafe.rerunFailingTestsCount>2</failsafe.rerunFailingTestsCount>
</properties>

<dependencies>
Expand Down Expand Up @@ -169,7 +172,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>jacoco-initialize</id>
Expand Down Expand Up @@ -319,8 +322,13 @@

<profiles>
<profile>
<id>ci</id>

<id>jacoco</id>
<activation>
<property>
<name>env.JACOCO</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -381,6 +389,7 @@
<defaults>
<sonar.issues.file>${sonar.working.directory}/${sonar.report.export.path}
</sonar.issues.file>
<sonar.skip>${sonar.skip}</sonar.skip>
</defaults>
<source>${project.basedir}/src/test/groovy/verify-sonar-issues.groovy</source>
</configuration>
Expand All @@ -399,10 +408,10 @@
</profile>

<profile>
<id>travis</id>
<id>coveralls</id>
<activation>
<property>
<name>env.TRAVIS</name>
<name>env.COVERALLS</name>
<value>true</value>
</property>
</activation>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package pl.wavesoftware.eid;

import javax.annotation.Nonnull;
import javax.annotation.meta.TypeQualifierDefault;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
* @author <a href="mailto:krzysztof.suszynski@wavesoftware.pl">Krzysztof Suszynski</a>
* @since 2016-03-26
*/
@Nonnull
@TypeQualifierDefault(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ReturnTypesAreNonnullByDefault {
}
34 changes: 9 additions & 25 deletions src/main/java/pl/wavesoftware/eid/exceptions/Eid.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package pl.wavesoftware.eid.exceptions;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.Serializable;
import java.util.ArrayList;
Expand All @@ -30,7 +29,7 @@
* <p>
* Exception identifier for all Eid Runtime Exceptions.
*
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
* @author <a href="mailto:krzysztof.suszynski@wavesoftware.pl">Krzysztof Suszynski</a>
*/
public class Eid implements Serializable {

Expand Down Expand Up @@ -62,7 +61,7 @@ public class Eid implements Serializable {

private final String ref;

private final Future<String> futureUniqueId;
private String uniqueId;

/**
* Constructor
Expand All @@ -71,7 +70,6 @@ public class Eid implements Serializable {
* @param ref an optional reference
*/
public Eid(String id, @Nullable String ref) {
futureUniqueId = new UniqFuture();
this.id = id;
this.ref = ref == null ? "" : ref;
}
Expand Down Expand Up @@ -170,17 +168,17 @@ public static String setRefFormat(String refFormat) {
* @param parameters a parameters for logMessageFormat to by passed to {@link String#format(String, Object...)}
* @return a formatted message
*/
public String makeLogMessage(@Nonnull String logMessageFormat, @Nonnull Object... parameters) {
public String makeLogMessage(String logMessageFormat, Object... parameters) {
String message = String.format(logMessageFormat, parameters);
return String.format(getMessageFormat(), this.toString(), message);
}

@Override
public String toString() {
if ("".equals(ref)) {
return String.format(format, id, futureUniqueId.get());
return String.format(format, id, getUniq());
}
return String.format(refFormat, id, ref, futureUniqueId.get());
return String.format(refFormat, id, ref, getUniq());
}

/**
Expand All @@ -207,7 +205,10 @@ public String getRef() {
* @return a unique string
*/
public String getUniq() {
return futureUniqueId.get();
if (uniqueId == null) {
uniqueId = uniqIdGenerator.generateUniqId();
}
return uniqueId;
}

private static void validateFormat(String format, int numSpecifiers) {
Expand Down Expand Up @@ -241,23 +242,6 @@ public interface UniqIdGenerator {
String generateUniqId();
}

private interface Future<T extends Serializable> extends Serializable {
T get();
}

private static final class UniqFuture implements Future<String> {
private static final long serialVersionUID = 20160325113314L;
private String future;
private UniqFuture() {}
@Override
public String get() {
if (future == null) {
future = uniqIdGenerator.generateUniqId();
}
return future;
}
}

private static final class StdUniqIdGenerator implements UniqIdGenerator {

private static final int BASE36 = 36;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* Indicate that object contains a Eid object
*
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
* @author <a href="mailto:krzysztof.suszynski@wavesoftware.pl">Krzysztof Suszynski</a>
*/
public interface EidContainer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @see IllegalArgumentException
* @see EidRuntimeException
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
* @author <a href="mailto:krzysztof.suszynski@wavesoftware.pl">Krzysztof Suszynski</a>
*/
public class EidIllegalArgumentException extends EidRuntimeException {

Expand Down Expand Up @@ -85,7 +85,6 @@ public EidIllegalArgumentException(Eid id, String messageFormat, Object... param
}

/**
* @inheritdoc
* @return {@link IllegalArgumentException} class
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @see IllegalStateException
* @see EidRuntimeException
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
* @author <a href="mailto:krzysztof.suszynski@wavesoftware.pl">Krzysztof Suszynski</a>
*/
public class EidIllegalStateException extends EidRuntimeException {

Expand Down Expand Up @@ -85,7 +85,6 @@ public EidIllegalStateException(Eid id, String messageFormat, Object... paramete
}

/**
* @inheritdoc
* @return {@link IllegalStateException} class
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @see IndexOutOfBoundsException
* @see EidRuntimeException
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
* @author <a href="mailto:krzysztof.suszynski@wavesoftware.pl">Krzysztof Suszynski</a>
*/
public class EidIndexOutOfBoundsException extends EidRuntimeException {

Expand Down Expand Up @@ -85,7 +85,6 @@ public EidIndexOutOfBoundsException(Eid id, String messageFormat, Object... para
}

/**
* @inheritdoc
* @return {@link IndexOutOfBoundsException} class
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
* @see NullPointerException
* @see EidRuntimeException
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
* @author <a href="mailto:krzysztof.suszynski@wavesoftware.pl">Krzysztof Suszynski</a>
*/
public class EidNullPointerException extends EidRuntimeException {

Expand Down Expand Up @@ -85,7 +85,6 @@ public EidNullPointerException(Eid id, String messageFormat, Object... parameter
}

/**
* @inheritdoc
* @return {@link NullPointerException} class
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* <p>
* For convenience use {@link pl.wavesoftware.eid.utils.EidPreconditions}
*
* @author Krzysztof Suszyński <krzysztof.suszynski@wavesoftware.pl>
* @author <a href="mailto:krzysztof.suszynski@wavesoftware.pl">Krzysztof Suszynski</a>
*/
public class EidRuntimeException extends RuntimeException implements EidContainer {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/**
* @author <a href="mailto:krzysztof.suszynski@coi.gov.pl">Krzysztof Suszynski</a>
* @since 29.03.16
*/
@javax.annotation.ParametersAreNonnullByDefault
@pl.wavesoftware.eid.ReturnTypesAreNonnullByDefault
package pl.wavesoftware.eid.exceptions;
Loading

0 comments on commit 9527517

Please sign in to comment.