Skip to content

Commit

Permalink
add some jsdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
UrielCh committed Mar 18, 2024
1 parent 123e907 commit def22d8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions accessors-smart/src/main/java/net/minidev/asm/ASMUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ public static Label[] newLabels(int cnt) {
}

/**
* Generates a setter method name for a given field name.
*
* @param key the field name
* @return setter name
*/
Expand All @@ -237,6 +239,8 @@ public static String getSetterName(String key) {
}

/**
* Generates a getter method name for a given field name.
*
* @param key the field name
* @return getter name
*/
Expand All @@ -257,6 +261,8 @@ public static String getGetterName(String key) {
}

/**
* Generates a boolean getter method name (is-method) for a given field name.
*
* @param key the boolean field name
* @return boolean getter name
*/
Expand Down
10 changes: 9 additions & 1 deletion accessors-smart/src/main/java/net/minidev/asm/Accessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public class Accessor {
* Filed Type using JDK 5+ generics if available
*/
protected Type genericType;

/**
* The name of the field.
*/
protected String fieldName;

/**
Expand Down Expand Up @@ -108,20 +110,26 @@ public Type getGenericType() {
}

/**
* Determines if the field is accessible for reading or writing operations.
*
* @return true if the field can be read or write
*/
public boolean isUsable() {
return field != null || getter != null || setter != null;
}

/**
* Checks if the field is readable, either directly or through a getter method.
*
* @return true if the field can be read
*/
public boolean isReadable() {
return field != null || getter != null;
}

/**
* Determines if the field is writable, either directly or through a setter method.
*
* @return true if the field can be write
*/
public boolean isWritable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* Allow access reflect field using runtime generated accessor. BeansAccessor is
* faster than java.lang.reflect.Method.invoke()
*
* @param <T> the type of the bean being accessed
* @author uriel Chemouni
*/
public abstract class BeansAccess<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type;

/**
* A builder class for dynamically creating {@link BeansAccess} classes for accessing bean properties efficiently.
* This class utilizes the ASM library to generate bytecode at runtime, thereby bypassing the need for Java reflection.
*/
public class BeansAccessBuilder {
static private String METHOD_ACCESS_NAME = Type.getInternalName(BeansAccess.class);

Expand All @@ -53,7 +57,7 @@ public class BeansAccessBuilder {
Class<? extends Exception> exceptionClass = NoSuchFieldException.class;

/**
* Build reflect bytecode from accessor list.
* Initializes a new builder instance for a given bean class.
*
* @param type
* type to be access
Expand Down

0 comments on commit def22d8

Please sign in to comment.