Skip to content

Commit

Permalink
Merge pull request #51 from creditdatamw/add-attribute-methods
Browse files Browse the repository at this point in the history
Add some more addAttribute methods to make developer experience better
  • Loading branch information
gpapadis committed Jul 8, 2021
2 parents 2c0215c + 19ee77c commit d31d52c
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions src/main/java/org/scify/jedai/datamodel/EntityProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
package org.scify.jedai.datamodel;

import java.io.Serializable;
import java.sql.Date;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.HashSet;
import java.util.Set;

Expand All @@ -43,6 +46,83 @@ public void addAttribute(String propertyName, String propertyValue) {
attributes.add(new Attribute(propertyName, propertyValue));
}

/**
* Add an integer attribute to the profile
*
* @param propertyName name of the attribute
* @param propertyValue value of the attribute
* @see String#valueOf(int)
*/
public void addAttribute(String propertyName, int propertyValue) {
attributes.add(new Attribute(propertyName, String.valueOf(propertyValue)));
}

/**
* Add an attribute to the profile
*
* @param propertyName name of the attribute
* @param propertyValue value of the attribute
* @see String#valueOf(long)
*/
public void addAttribute(String propertyName, long propertyValue) {
attributes.add(new Attribute(propertyName, String.valueOf(propertyValue)));
}

/**
* Add an attribute to the profile
*
* @param propertyName name of the attribute
* @param propertyValue value of the attribute
* @see String#valueOf(float)
*/
public void addAttribute(String propertyName, float propertyValue) {
attributes.add(new Attribute(propertyName, String.valueOf(propertyValue)));
}

/**
* Add an attribute to the profile
*
* @param propertyName name of the attribute
* @param propertyValue value of the attribute
* @see String#valueOf(double)
*/
public void addAttribute(String propertyName, double propertyValue) {
attributes.add(new Attribute(propertyName, String.valueOf(propertyValue)));
}

/**
* Add an attribute to the profile
*
* @param propertyName name of the attribute
* @param propertyValue value of the attribute
* @see String#valueOf(Object)
*/
public void addAttribute(String propertyName, Date propertyValue) {
attributes.add(new Attribute(propertyName, String.valueOf(propertyValue)));
}

/**
* Add an attribute to the profile
*
* @param propertyName name of the attribute
* @param propertyValue local date value of the attribute
* @see LocalDate#format(DateTimeFormatter)
*/
public void addAttribute(String propertyName, LocalDate propertyValue) {
attributes.add(new Attribute(propertyName, propertyValue.format(DateTimeFormatter.ISO_DATE)));
}

/**
* Add an attribute to the profile
*
* @param propertyName name of the attribute
* @param propertyValue local date value of the attribute
* @see LocalDate#format(DateTimeFormatter)
*/
public void addAttribute(String propertyName, LocalDate propertyValue, DateTimeFormatter formatter) {
attributes.add(new Attribute(propertyName, propertyValue.format(formatter)));
}

public String getEntityUrl() {
return entityUrl;
}
Expand Down

0 comments on commit d31d52c

Please sign in to comment.