Skip to content

Commit

Permalink
Fix JavaDoc to comply with CheckStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
PhantomYdn committed Feb 6, 2024
1 parent ff33bde commit 7ba3c4c
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private <T> DynamicType.Builder<T> enhanceCasesByOverrides(DynamicType.Builder<T
.collect(Collectors.toMap(m->m.asSignatureToken(), m->m, (k1, k2) -> k1));
List<Case> casesToAdd = type.getInterfaces().stream()
.flatMap(i->CommonUtils.getMethodDescriptionList(i).stream())
.filter(OverrideByThis.ANNOTED_BY_THIS_MATCHER::matches)
.filter(OverrideByThis.ANNOTATED_BY_THIS_MATCHER::matches)
.filter(m -> {
//Checking that original method is present per signature
//and that it's not exactly the same method as we are trying to use to override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,10 +509,22 @@ public boolean matches(T target) {
};
}

/**
* Provides {@link ElementMatcher} to check whether methods are similiar from provided type
* @param <T> type of a required matcher
* @param type class to check methods from
* @return mathcher to use for check
*/
public <T extends MethodDescription> ElementMatcher<T> isSimiliarToMethodIn(Class<?> type) {
return isSimiliarToMethodIn(TypeDescription.ForLoadedType.of(type));
}

/**
* Provides {@link ElementMatcher} to check whether methods are similiar from provided type
* @param <T> type of a required matcher
* @param type class to check methods from
* @return mathcher to use for check
*/
public <T extends MethodDescription> ElementMatcher<T> isSimiliarToMethodIn(TypeDescription type) {
return new ElementMatcher.Junction.AbstractBase<T>() {

Expand All @@ -523,10 +535,22 @@ public boolean matches(T target) {
};
}

/**
* Provides {@link ElementMatcher} to check whether method is present in provided type
* @param <T> type of a required matcher
* @param type class to check method in
* @return mathcher to use for check
*/
public <T extends MethodDescription> ElementMatcher<T> isMethodPresent(Class<?> type) {
return isMethodPresent(TypeDescription.ForLoadedType.of(type));
}

/**
* Provides {@link ElementMatcher} to check whether method is present in provided type
* @param <T> type of a required matcher
* @param type class to check method in
* @return mathcher to use for check
*/
public <T extends MethodDescription> ElementMatcher<T> isMethodPresent(TypeDescription type) {
return new ElementMatcher.Junction.AbstractBase<T>() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import org.orienteer.transponder.Transponder.ITransponderHolder;
import org.orienteer.transponder.mutator.StackedMutator;

/**
* ByteBuddy proxy type to use
*/
public enum ProxyType {
ENTITY("entity", ITransponderEntity.class, StackedMutator.ENTITY_MUTATOR),
DAO("dao", ITransponderHolder.class, StackedMutator.DAO_MUTATOR),
Expand All @@ -21,14 +24,26 @@ public enum ProxyType {
this.rootMutator = rootMutator;
}

/**
* Provides default suffix for ByteBuddy generated classes
* @return default suffix for ByteBuddy generated classes
*/
public String getDefaultPackageSuffix() {
return packageSuffix;
}

/**
* Provides required Transponder Interface to be implemented
* @return required Transponder Interface to be implemented
*/
public Class<?> getTransponderInterfaceToImplement() {
return transponderInterfaceToImplement;
}

/**
* Provides Root Mutator for current proxy type
* @return Root Mutator for current proxy type
*/
public IMutator getRootMutator() {
return rootMutator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ public static interface ITransponderEntity extends ITransponderHolder{

}

/**
* Interface-marker to designate classes which delegates
* @param <T> type of a delegate
*/
public static interface ITransponderDelegator<T> extends ITransponderHolder{
//CHECKSTYLE IGNORE MethodName FOR NEXT 8 LINES
/**
Expand Down Expand Up @@ -419,6 +423,13 @@ public <T> T dao(Class<T> mainClass, final Class<?>... additionalInterfaces) {
return setTransponder(driver.newDAOInstance(getProxyClass(Object.class, mainClass, ProxyType.DAO, additionalInterfaces)));
}

/**
* Provides proxy delegate with all required interfaces
* @param <T> type of proxy delegate
* @param delegate instance to delegate to
* @param additionalInterfaces additional interfaces to be implemented
* @return generated instance
*/
public <T> T delegate(T delegate, final Class<?>... additionalInterfaces) {
Class<T> delegateClass = (Class<T>)delegate.getClass();
Class<T> proxyClass = getProxyClass(delegateClass, delegateClass, ProxyType.DELEGATE, additionalInterfaces);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
import net.bytebuddy.matcher.ElementMatcher;
import net.bytebuddy.matcher.ElementMatchers;

/**
* Annotation for methods to enforce overriding by this method
*/
@Retention(RUNTIME)
@Target(METHOD)
public @interface OverrideByThis {

public static final ElementMatcher<AnnotationSource> ANNOTED_BY_THIS_MATCHER
public static final ElementMatcher<AnnotationSource> ANNOTATED_BY_THIS_MATCHER
= ElementMatchers.isAnnotatedWith(OverrideByThis.class);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.orienteer.transponder.CommonUtils;
import org.orienteer.transponder.IMutator;
import org.orienteer.transponder.Transponder;
import org.orienteer.transponder.annotation.Command;

import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.description.type.TypeDescription.Generic;
Expand All @@ -15,6 +16,9 @@

import static net.bytebuddy.matcher.ElementMatchers.*;

/**
* {@link IMutator} and delegate to implement methods from provided delegate
*/
public class DelegatorMutator implements IMutator {

@Override
Expand Down

0 comments on commit 7ba3c4c

Please sign in to comment.