Skip to content

Commit

Permalink
add a few missing javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
efekos committed Oct 1, 2024
1 parent c1daaa1 commit bd15ccb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/main/java/dev/efekos/simple_ql/data/AdaptedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,40 @@ public class AdaptedList<T> implements TableRowTypeAdapter, Iterable<T> {
private final List<T> list;
private final Implementor<T, String> implementor;

/**
* Creates a new list.
* @param implementor Implementor that will be used while converting this list into a {@link String}.
*/
public AdaptedList(Implementor<T, String> implementor) {
this.list = new ArrayList<>();
this.implementor = implementor;
}

/**
* Creates a clone of the given list.
* @param list A list to add elements of.
* @param implementor Implementor that will be used while converting this list into a {@link String}.
*/
public AdaptedList(List<T> list, Implementor<T, String> implementor) {
this.list = list;
this.implementor = implementor;
}

/**
* Returns a clone of the given list.
* @param list Any {@link AdaptedList}.
* @return Clone of the given list.
* @param <TY> Type of the list.
*/
public static <TY> AdaptedList<TY> clone(AdaptedList<TY> list) {
return new AdaptedList<>(list.list, list.implementor);
}

/**
* Reads the given {@link String} and converts it into a {@link AdaptedList}.
* @param i Input string.
* @return A {@link AdaptedList} instance that represents the given {@link String}.
*/
@SuppressWarnings("unchecked")
public static AdaptedList<Object> readAdapted(String i) {
String[] split = i.split(IMPLEMENTOR_SEPARATOR + "");
Expand All @@ -108,6 +128,10 @@ public static AdaptedList<Object> readAdapted(String i) {
}
}

/**
* Converts this list into a {@link String}.
* @return A string.
*/
@Override
public String adapt() {
if (list.isEmpty()) return implementor.getClass().getName() + IMPLEMENTOR_SEPARATOR + ARRAY_START + ARRAY_END;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/dev/efekos/simple_ql/data/TableRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public void markDirty() {
for (Field field : clazz.getDeclaredFields()) markDirty(field.getName());
}

/**
* Marks a specific field dirty. Should be used by EVERY setter in order for a {@link TableRow} subclass to work.
* @param name Name of the field/column.
*/
protected void markDirty(String name) {
dirtyFields.add(name);
}
Expand Down

0 comments on commit bd15ccb

Please sign in to comment.