diff --git a/pom.xml b/pom.xml index 05fb5e41..a433e8bf 100644 --- a/pom.xml +++ b/pom.xml @@ -32,8 +32,8 @@ 4.0.0 com.jcabi - jcabi - 0.7.22 + parent + 0.9 jcabi-aspects 0.11 @@ -53,6 +53,17 @@ scm:git:github.com:jcabi/jcabi-aspects.git https://github.com/jcabi/jcabi-aspects + + + + www.jcabi.com + s3://www.jcabi.com/jcabi-aspects + + com.jcabi diff --git a/src/main/java/com/jcabi/aspects/aj/MethodLogger.java b/src/main/java/com/jcabi/aspects/aj/MethodLogger.java index 76ae1fde..0423def2 100644 --- a/src/main/java/com/jcabi/aspects/aj/MethodLogger.java +++ b/src/main/java/com/jcabi/aspects/aj/MethodLogger.java @@ -306,6 +306,69 @@ private static boolean enabled(final int level, final Class log) { return enabled; } + /** + * Checks whether array of types contains given type. + * @param array Array of them + * @param exp The exception to find + * @return TRUE if it's there + */ + private static boolean contains(final Class[] array, + final Throwable exp) { + boolean contains = false; + for (Class type : array) { + if (MethodLogger.instanceOf(exp.getClass(), type)) { + contains = true; + break; + } + } + return contains; + } + + /** + * The type is an instance of another type? + * @param child The child type + * @param parent Parent type + * @return TRUE if child is really a child of a parent + */ + private static boolean instanceOf(final Class child, + final Class parent) { + boolean instance = child.equals(parent) + || (child.getSuperclass() != null + && MethodLogger.instanceOf(child.getSuperclass(), parent)); + if (!instance) { + for (Class iface : child.getInterfaces()) { + instance = MethodLogger.instanceOf(iface, parent); + if (instance) { + break; + } + } + } + return instance; + } + + /** + * Textualize a stacktrace. + * @param trace Array of stacktrace elements + * @return The text + */ + private static String textualize(final StackTraceElement[] trace) { + final StringBuilder text = new StringBuilder(); + for (int pos = 0; pos < trace.length; ++pos) { + if (text.length() > 0) { + text.append(", "); + } + text.append( + String.format( + "%s#%s[%d]", + trace[pos].getClassName(), + trace[pos].getMethodName(), + trace[pos].getLineNumber() + ) + ); + } + return text.toString(); + } + /** * Marker of a running method. */ @@ -405,67 +468,4 @@ public int compareTo(final Marker marker) { } } - /** - * Checks whether array of types contains given type. - * @param array Array of them - * @param exp The exception to find - * @return TRUE if it's there - */ - private static boolean contains(final Class[] array, - final Throwable exp) { - boolean contains = false; - for (Class type : array) { - if (MethodLogger.instanceOf(exp.getClass(), type)) { - contains = true; - break; - } - } - return contains; - } - - /** - * The type is an instance of another type? - * @param child The child type - * @param parent Parent type - * @return TRUE if child is really a child of a parent - */ - private static boolean instanceOf(final Class child, - final Class parent) { - boolean instance = child.equals(parent) - || (child.getSuperclass() != null - && MethodLogger.instanceOf(child.getSuperclass(), parent)); - if (!instance) { - for (Class iface : child.getInterfaces()) { - instance = MethodLogger.instanceOf(iface, parent); - if (instance) { - break; - } - } - } - return instance; - } - - /** - * Textualize a stacktrace. - * @param trace Array of stacktrace elements - * @return The text - */ - private static String textualize(final StackTraceElement[] trace) { - final StringBuilder text = new StringBuilder(); - for (int pos = 0; pos < trace.length; ++pos) { - if (text.length() > 0) { - text.append(", "); - } - text.append( - String.format( - "%s#%s[%d]", - trace[pos].getClassName(), - trace[pos].getMethodName(), - trace[pos].getLineNumber() - ) - ); - } - return text.toString(); - } - } diff --git a/src/main/java/com/jcabi/immutable/ArrayMap.java b/src/main/java/com/jcabi/immutable/ArrayMap.java index 4363be82..ac5ce816 100644 --- a/src/main/java/com/jcabi/immutable/ArrayMap.java +++ b/src/main/java/com/jcabi/immutable/ArrayMap.java @@ -63,26 +63,6 @@ @SuppressWarnings({ "rawtypes", "unchecked", "PMD.TooManyMethods" }) public final class ArrayMap implements ConcurrentMap { - /** - * Comparator. - */ - private static final class Cmp implements - Comparator> { - @Override - public int compare(final ImmutableEntry left, - final ImmutableEntry right) { - int compare; - if (left.getKey() instanceof Comparable) { - compare = Comparable.class.cast(left.getKey()) - .compareTo(right.getKey()); - } else { - compare = left.getKey().toString() - .compareTo(right.getKey().toString()); - } - return compare; - } - } - /** * All entries. */ @@ -375,6 +355,26 @@ public Set> entrySet() { ); } + /** + * Comparator. + */ + private static final class Cmp implements + Comparator> { + @Override + public int compare(final ImmutableEntry left, + final ImmutableEntry right) { + int compare; + if (left.getKey() instanceof Comparable) { + compare = Comparable.class.cast(left.getKey()) + .compareTo(right.getKey()); + } else { + compare = left.getKey().toString() + .compareTo(right.getKey().toString()); + } + return compare; + } + } + /** * Immutable map entry. */ diff --git a/src/main/java/com/jcabi/immutable/ArraySortedSet.java b/src/main/java/com/jcabi/immutable/ArraySortedSet.java index 3b12641d..71ae207f 100644 --- a/src/main/java/com/jcabi/immutable/ArraySortedSet.java +++ b/src/main/java/com/jcabi/immutable/ArraySortedSet.java @@ -57,47 +57,6 @@ @SuppressWarnings({ "unchecked", "PMD.TooManyMethods" }) public final class ArraySortedSet implements SortedSet { - /** - * Comparator. - * @param Type of argument - */ - @Immutable - public interface Comparator extends java.util.Comparator { - /** - * Default comparator. - * @param Type of argument - */ - @Immutable - final class Default implements ArraySortedSet.Comparator { - @Override - public int compare(final T left, final T right) { - return Comparable.class.cast(left).compareTo(right); - } - }; - /** - * Neutral comparator (never compares). - * @param Type of argument - */ - @Immutable - final class Neutral implements ArraySortedSet.Comparator { - @Override - public int compare(final T left, final T right) { - return 1; - } - }; - /** - * Reverse comparator. - * @param Type of argument - */ - @Immutable - final class Reverse implements ArraySortedSet.Comparator { - @Override - public int compare(final T left, final T right) { - return Comparable.class.cast(right).compareTo(left); - } - }; - }; - /** * All values. */ @@ -389,4 +348,45 @@ public void clear() { throw new UnsupportedOperationException(); } + /** + * Comparator. + * @param Type of argument + */ + @Immutable + public interface Comparator extends java.util.Comparator { + /** + * Default comparator. + * @param Type of argument + */ + @Immutable + final class Default implements ArraySortedSet.Comparator { + @Override + public int compare(final T left, final T right) { + return Comparable.class.cast(left).compareTo(right); + } + }; + /** + * Neutral comparator (never compares). + * @param Type of argument + */ + @Immutable + final class Neutral implements ArraySortedSet.Comparator { + @Override + public int compare(final T left, final T right) { + return 1; + } + }; + /** + * Reverse comparator. + * @param Type of argument + */ + @Immutable + final class Reverse implements ArraySortedSet.Comparator { + @Override + public int compare(final T left, final T right) { + return Comparable.class.cast(right).compareTo(left); + } + }; + }; + }