Commit 8da85ef0 authored by Mathieu Féry (Mathius)'s avatar Mathieu Féry (Mathius)
Browse files

Work in doc and Annotation in api.dnd

parent da5f4efd
......@@ -40,6 +40,7 @@ public class DnDAttr implements Serializable {
* @return toString
*/
@Override
@NonNull
public String toString() {
return String.format("%s : %s", nameAttr, valueUserReadable);
}
......
......@@ -26,6 +26,7 @@ public class DnDAttrs implements Serializable {
* @return toString
*/
@Override
@NonNull
public String toString() {
String out = "";
for (DnDAttr attr : attrs)
......@@ -38,6 +39,7 @@ public class DnDAttrs implements Serializable {
* @param nameAttr
* @return attr
*/
@Nullable
public DnDAttr get(@NonNull String nameAttr) {
for (DnDAttr attr : attrs)
if (attr.nameAttr.toLowerCase().equals(nameAttr.toLowerCase()))
......
......@@ -8,30 +8,57 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
/**
* DnDClass is a class representing the character’s class with possibly the search parameter to
* retrieve cards of that class only
*/
public class DnDClass implements Serializable, Comparable<DnDClass> {
public String queryArg;
public String name;
/**
* Basic Constructor for create class if queryArg is missing
* @param name
*/
public DnDClass(@NonNull String name) {
this(name, null);
}
/**
* Basic Constructor for create attribute if all arguments are provided.
* @param name
* @param queryArg
*/
public DnDClass(@NonNull String name, @Nullable String queryArg) {
this.name = name;
this.queryArg = queryArg;
}
/**
* For write class.
* @return toString
*/
@Override
@NonNull
public String toString() {
return this.name;
}
/**
* For identify attributes.
* @return hashCode
*/
@Override
public int hashCode() {
return this.name.hashCode();
}
/**
* For compare Any Object with this class.
* @param obj
* @return equals
*/
@Override
public boolean equals(@Nullable Object obj) {
if (obj != null && obj.getClass() == this.getClass())
......@@ -65,6 +92,7 @@ public class DnDClass implements Serializable, Comparable<DnDClass> {
* For get random class from the API.
* @return class
*/
@NonNull
public static DnDClass getRandomClass() {
return getRandomClass(classes);
}
......@@ -74,10 +102,16 @@ public class DnDClass implements Serializable, Comparable<DnDClass> {
* @param dnDclass
* @return class
*/
@NonNull
public static DnDClass getRandomClass(@NonNull List<DnDClass> dnDclass) {
return dnDclass.get(new Random().nextInt(dnDclass.size()));
}
/**
* For compare 2 class
* @param o
* @return compareToResult
*/
@Override
public int compareTo(DnDClass o) {
return this.name.compareTo(o.name);
......
package fr.iutnantes.miar.dndgenerator.api.dnd;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.io.Serializable;
......@@ -35,6 +36,7 @@ public class DnDSaves implements Serializable {
* @return toString
*/
@Override
@NonNull
public String toString() {
String out = "";
String[] labels = new String[]{"wands", "breath", "stone", "magic", "poison"};
......
......@@ -28,6 +28,7 @@ public class DnDSkill implements Serializable {
* For write skill.
* @return toString
*/
@NonNull
@Override
public String toString() {
return String.format("%s : %s", skillName, value);
......
......@@ -28,6 +28,7 @@ public class DnDSkills implements Serializable {
* For write skills.
* @return toString
*/
@NonNull
@Override
public String toString() {
String out = "";
......
......@@ -38,6 +38,7 @@ public class DnDSystem implements Serializable, Comparable<DnDSystem> {
* For write system.
* @return toString
*/
@NonNull
@Override
public String toString(){
return String.format("System of %s", longName);
......@@ -125,6 +126,11 @@ public class DnDSystem implements Serializable, Comparable<DnDSystem> {
return false;
}
/**
* For compare 2 system
* @param o
* @return compareToResult
*/
@Override
public int compareTo(DnDSystem o) {
return this.longName.compareTo(o.longName);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment