Skip to content

Commit 97aa35b

Browse files
committed
house keeping
1 parent 700fc08 commit 97aa35b

File tree

7 files changed

+6
-39
lines changed

7 files changed

+6
-39
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ jobs:
2727
env:
2828
CENTRAL_OSSRH_USERNAME: ${{ secrets.CENTRAL_OSSRH_USERNAME }}
2929
CENTRAL_OSSRH_PASSWORD: ${{ secrets.CENTRAL_OSSRH_PASSWORD }}
30-
run: ./mvnw -B package
30+
run: ./mvnw -B test
3131
# run: ./mvnw -B deploy -s settings.xml

jmolecules-bytebuddy/src/main/java/org/jmolecules/bytebuddy/ClassWorld.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ class ClassWorld {
2626
private final ClassFileLocator locator;
2727

2828
boolean isAvailable(String name) {
29-
3029
try {
3130
return locator.locate(name).isResolved();
32-
} catch (IOException o_O) {
31+
} catch (IOException e) {
3332
return false;
3433
}
3534
}

jmolecules-bytebuddy/src/main/java/org/jmolecules/bytebuddy/JMoleculesPlugin.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public JMoleculesPlugin(File outputFolder) {
5454

5555
@Override
5656
public void onPreprocess(TypeDescription typeDescription, ClassFileLocator classFileLocator) {
57-
5857
if (!configuration.include(typeDescription)) {
5958
return;
6059
}
@@ -88,7 +87,6 @@ public boolean matches(TypeDescription target) {
8887
@Override
8988
@SuppressWarnings({ "unchecked", "rawtypes" })
9089
public Builder<?> apply(Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator) {
91-
9290
return delegates.get(typeDescription).stream().reduce(builder,
9391
(it, plugin) -> (Builder) plugin.apply(it, typeDescription, classFileLocator), (left, right) -> right);
9492
}

jmolecules-bytebuddy/src/main/java/org/jmolecules/bytebuddy/JMoleculesType.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class JMoleculesType {
3434
* @param type must not be {@literal null}.
3535
*/
3636
JMoleculesType(TypeDescription type) {
37-
3837
if (type == null) {
3938
throw new IllegalArgumentException("TypeDescription must not be null!");
4039
}

jmolecules-bytebuddy/src/main/java/org/jmolecules/bytebuddy/LoggingPlugin.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@
2626
*/
2727
public interface LoggingPlugin extends Plugin {
2828

29-
/*
30-
* (non-Javadoc)
31-
* @see java.io.Closeable#close()
32-
*/
3329
@Override
3430
public default void close() throws IOException {
3531
PluginLogger.INSTANCE.flush();

jmolecules-bytebuddy/src/main/java/org/jmolecules/bytebuddy/PluginLogger.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ enum PluginLogger {
4646
* @return will never be {@literal null}.
4747
*/
4848
public Log getLog(TypeDescription description, String name) {
49-
5049
if (description == null) {
5150
throw new IllegalArgumentException("TypeDescription must not be null!");
5251
}
@@ -56,20 +55,16 @@ public Log getLog(TypeDescription description, String name) {
5655
}
5756

5857
Set<LogEntry> moduleLogs = logs.computeIfAbsent(description.getName(), it -> new TreeSet<>());
59-
6058
return (message, parameters) -> moduleLogs.add(new LogEntry(name, message, parameters));
6159
}
6260

6361
public void flush() {
64-
6562
try {
66-
6763
if (!logs.isEmpty()) {
6864
log.info("");
6965
}
7066

7167
logs.forEach((description, moduleLogs) -> {
72-
7368
if (moduleLogs.isEmpty()) {
7469
return;
7570
}
@@ -107,10 +102,6 @@ private static class LogEntry implements Comparable<LogEntry> {
107102
String message;
108103
Object[] parameters;
109104

110-
/*
111-
* (non-Javadoc)
112-
* @see java.lang.Comparable#compareTo(java.lang.Object)
113-
*/
114105
@Override
115106
public int compareTo(LogEntry o) {
116107

@@ -125,4 +116,5 @@ private String getExpandedMessage() {
125116
return String.format(message.replace("{}", "%s"), parameters);
126117
}
127118
}
119+
128120
}

jmolecules-bytebuddy/src/main/java/org/jmolecules/bytebuddy/PluginUtils.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class PluginUtils {
5858
* @return result of the check.
5959
*/
6060
static boolean isAnnotatedWith(TypeDescription type, Class<?> annotationType) {
61-
6261
return type.getDeclaredAnnotations() //
6362
.asTypeList() //
6463
.stream() //
@@ -100,9 +99,7 @@ static Builder<?> mapAnnotationOrInterfaces(Builder<?> builder, TypeDescription
10099
Map<Class<?>, Class<? extends Annotation>> mappings, Log log) {
101100

102101
for (Entry<Class<?>, Class<? extends Annotation>> entry : mappings.entrySet()) {
103-
104102
Class<?> source = entry.getKey();
105-
106103
if (source.isAnnotation() ? isAnnotatedWith(type, source) : type.isAssignableTo(source)) {
107104
builder = addAnnotationIfMissing(entry.getValue(), builder, type, log);
108105
}
@@ -235,9 +232,7 @@ public T get() {
235232
* @return output for the log.
236233
*/
237234
static String toLog(FieldDescription field) {
238-
239235
TypeDefinition type = field.getDeclaringType();
240-
241236
return abbreviate(type).concat(".").concat(field.getName());
242237
}
243238

@@ -248,10 +243,9 @@ static String toLog(FieldDescription field) {
248243
* @param consumer must not be {@literal null}.
249244
*/
250245
static void ifTypePresent(String fullyQualifiedTypeName, Consumer<Class<?>> consumer) {
251-
252246
try {
253247
consumer.accept(PluginUtils.class.getClassLoader().loadClass(fullyQualifiedTypeName));
254-
} catch (ClassNotFoundException o_O) {}
248+
} catch (ClassNotFoundException e) {}
255249
}
256250

257251
/**
@@ -262,11 +256,10 @@ static void ifTypePresent(String fullyQualifiedTypeName, Consumer<Class<?>> cons
262256
*/
263257
@SuppressWarnings("unchecked")
264258
static void ifAnnotationTypePresent(String fullyQualifiedTypeName, Consumer<Class<? extends Annotation>> consumer) {
265-
266259
try {
267260
consumer
268261
.accept((Class<? extends Annotation>) PluginUtils.class.getClassLoader().loadClass(fullyQualifiedTypeName));
269-
} catch (ClassNotFoundException o_O) {}
262+
} catch (ClassNotFoundException e) {}
270263
}
271264

272265
/**
@@ -286,7 +279,6 @@ static boolean isCglibProxyType(TypeDefinition definition) {
286279
* @return since 0.26
287280
*/
288281
static MethodDefinition<?> markGenerated(MethodDefinition<?> method) {
289-
290282
return getGeneratedTypeAnnotation(ElementType.METHOD)
291283
.<MethodDefinition<?>> map(method::annotateMethod)
292284
.orElse(method);
@@ -301,7 +293,6 @@ static MethodDefinition<?> markGenerated(MethodDefinition<?> method) {
301293
* @since 0.26
302294
*/
303295
static Builder<?> markGenerated(Builder<?> builder, Log log) {
304-
305296
return getGeneratedTypeAnnotation(ElementType.TYPE)
306297
.map(it -> {
307298

@@ -316,34 +307,27 @@ static Builder<?> markGenerated(Builder<?> builder, Log log) {
316307

317308
private static Builder<?> addAnnotationIfMissing(Class<? extends Annotation> annotation, Builder<?> builder,
318309
TypeDescription type, Log log) {
319-
320310
if (isAnnotatedWith(type, annotation)) {
321311
log.info("Not adding @{}, already present.", PluginUtils.abbreviate(annotation));
322312
return builder;
323313
}
324314

325315
log.info("Adding @{}.", PluginUtils.abbreviate(annotation));
326-
327316
return builder.annotateType(getAnnotation(annotation));
328317
}
329318

330319
private static String getPackageName(String fullyQualifiedTypeName) {
331-
332320
int lastDotIndex = fullyQualifiedTypeName.lastIndexOf('.');
333-
334321
return lastDotIndex == -1 ? fullyQualifiedTypeName : fullyQualifiedTypeName.substring(0, lastDotIndex);
335322
}
336323

337324
private static String getShortName(String fullyQualifiedTypeName) {
338-
339325
int lastDotIndex = fullyQualifiedTypeName.lastIndexOf('.');
340-
341326
return lastDotIndex == -1 ? fullyQualifiedTypeName
342327
: fullyQualifiedTypeName.substring(lastDotIndex, fullyQualifiedTypeName.length());
343328
}
344329

345330
private static Optional<AnnotationDescription> getGeneratedTypeAnnotation(ElementType type) {
346-
347331
return Types.AT_GENERATED.stream()
348332
.filter(it -> hasTarget(it, type))
349333
.findFirst()
@@ -354,9 +338,8 @@ private static Optional<AnnotationDescription> getGeneratedTypeAnnotation(Elemen
354338
}
355339

356340
private static boolean hasTarget(Class<? extends Annotation> type, ElementType target) {
357-
358341
Target annotation = type.getAnnotation(Target.class);
359-
360342
return annotation != null && Arrays.asList(annotation.value()).contains(target);
361343
}
344+
362345
}

0 commit comments

Comments
 (0)