Skip to content

Commit

Permalink
Fix JsonFormatter static methods
Browse files Browse the repository at this point in the history
  • Loading branch information
minborg committed Aug 26, 2015
1 parent bc098e4 commit 44fd108
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Expand Up @@ -195,10 +195,10 @@ protected static String jsonValue(Object in) {
* renderer.
*
* @param <ENTITY> the Entity type
* @param entityClass the class of the ENTITY
* @param manager of the entity
* @return a new JsonFormatter with no fields added to the renderer
*/
public static <ENTITY> JsonFormatter<ENTITY> noneOf(Class<ENTITY> entityClass) {
public static <ENTITY> JsonFormatter<ENTITY> noneOf(Manager<ENTITY> manager) {
return new JsonFormatter<>();
}

Expand All @@ -216,13 +216,12 @@ public static <ENTITY> JsonFormatter<ENTITY> noneOf(Class<ENTITY> entityClass) {
*
* @param <ENTITY> the Entity type
* @param manager of the entity
* @param entityClass the class of the ENTITY
* @return a new JsonFormatter with all the Entity fields added to the
* renderer
*/
public static <ENTITY> JsonFormatter<ENTITY> allOf(Manager<ENTITY> manager, Class<ENTITY> entityClass) {
public static <ENTITY> JsonFormatter<ENTITY> allOf(Manager<ENTITY> manager) {

final JsonFormatter<ENTITY> formatter = noneOf(entityClass);
final JsonFormatter<ENTITY> formatter = noneOf(manager);

final Table table = manager.getTable();

Expand Down Expand Up @@ -253,16 +252,15 @@ public static <ENTITY> JsonFormatter<ENTITY> allOf(Manager<ENTITY> manager, Clas
*
* @param <ENTITY> the Entity type
* @param manager of the ENTITY
* @param entityClass the class of the ENTITY
* @param fields to add to the output renderer
* @return a new JsonFormatter with the specified fields added to the
* renderer
*
*/
@SafeVarargs
@SuppressWarnings("varargs") // Using the array in a Stream.of() is safe
public static <ENTITY> JsonFormatter<ENTITY> of(Manager<ENTITY> manager, Class<ENTITY> entityClass, Field<ENTITY>... fields) {
final JsonFormatter<ENTITY> formatter = noneOf(entityClass);
public static <ENTITY> JsonFormatter<ENTITY> of(Manager<ENTITY> manager, Field<ENTITY>... fields) {
final JsonFormatter<ENTITY> formatter = noneOf(manager);

final Set<String> fieldNames = Stream.of(fields).map(Field::getColumnName).collect(toSet());
final Table table = manager.getTable();
Expand Down
Expand Up @@ -55,7 +55,7 @@ public AbstractManager(Speedment speedment) {
updateListeners = new CopyOnWriteArraySet<>();
deleteListeners = new CopyOnWriteArraySet<>();
state = Lifecyclable.State.CREATED;
sharedJasonFormatter = JsonFormatter.allOf(this, getEntityClass());
sharedJasonFormatter = JsonFormatter.allOf(this);
}

protected void insertEvent(ENTITY entity) {
Expand Down

0 comments on commit 44fd108

Please sign in to comment.