Formatting and Refactoring
This commit is contained in:
parent
15338dce52
commit
05ffa34ec0
@ -23,7 +23,7 @@ public abstract class Contact implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Creates a new instance of a {@link Contact}.
|
* Creates a new instance of a {@link Contact}.
|
||||||
*
|
*
|
||||||
* @param id the id of this contact
|
* @param id the ID of this contact
|
||||||
* @param name the name of this contact
|
* @param name the name of this contact
|
||||||
* @since Envoy Common v0.1-beta
|
* @since Envoy Common v0.1-beta
|
||||||
*/
|
*/
|
||||||
@ -45,12 +45,13 @@ public abstract class Contact implements Serializable {
|
|||||||
public String getName() { return name; }
|
public String getName() { return name; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param newName the new name of this {@link Contact}
|
* @param name the new name of this {@link Contact}
|
||||||
* @since Envoy Common v0.1-beta
|
* @since Envoy Common v0.1-beta
|
||||||
*/
|
*/
|
||||||
public void setName(String newName) { name = newName; }
|
public void setName(String name) { this.name = name; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,15 +14,15 @@ import java.util.StringJoiner;
|
|||||||
*/
|
*/
|
||||||
public class Group extends Contact {
|
public class Group extends Contact {
|
||||||
|
|
||||||
private static final long serialVersionUID = 0L;
|
|
||||||
|
|
||||||
// TODO add admins
|
// TODO add admins
|
||||||
private List<Long> memberIDs;
|
private List<Long> memberIDs;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 0L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance of a {@link Group}.
|
* Creates a new instance of a {@link Group}.
|
||||||
*
|
*
|
||||||
* @param id the id of this group
|
* @param id the ID of this group
|
||||||
* @param name the name of this group
|
* @param name the name of this group
|
||||||
* @since Envoy Common v0.1-beta
|
* @since Envoy Common v0.1-beta
|
||||||
*/
|
*/
|
||||||
@ -31,7 +31,7 @@ public class Group extends Contact {
|
|||||||
/**
|
/**
|
||||||
* Creates a new instance of a {@link Group}.
|
* Creates a new instance of a {@link Group}.
|
||||||
*
|
*
|
||||||
* @param id the id of this group
|
* @param id the ID of this group
|
||||||
* @param name the name of this group
|
* @param name the name of this group
|
||||||
* @param memberIDs the IDs of all members that should be preinitialized
|
* @param memberIDs the IDs of all members that should be preinitialized
|
||||||
* @since Envoy Common v0.1-beta
|
* @since Envoy Common v0.1-beta
|
||||||
@ -61,7 +61,7 @@ public class Group extends Contact {
|
|||||||
var joiner = new StringJoiner(",", "Group[id=", "]");
|
var joiner = new StringJoiner(",", "Group[id=", "]");
|
||||||
joiner.add("id=" + getID());
|
joiner.add("id=" + getID());
|
||||||
joiner.add("name=" + getName());
|
joiner.add("name=" + getName());
|
||||||
joiner.add("memberIDs=" + getMemberIDs());
|
joiner.add("members=" + getMemberIDs().size());
|
||||||
return joiner.toString();
|
return joiner.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,5 +19,4 @@ public class GroupCreationEvent extends Event<String> {
|
|||||||
* @since Envoy Common v0.1-beta
|
* @since Envoy Common v0.1-beta
|
||||||
*/
|
*/
|
||||||
public GroupCreationEvent(String value) { super(value); }
|
public GroupCreationEvent(String value) { super(value); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,14 @@ import envoy.data.User;
|
|||||||
public class GroupResizeEvent extends Event<Long> {
|
public class GroupResizeEvent extends Event<Long> {
|
||||||
|
|
||||||
private final long groupID;
|
private final long groupID;
|
||||||
private OperationType operationType;
|
private Operation operation;
|
||||||
|
|
||||||
private static final long serialVersionUID = 0L;
|
private static final long serialVersionUID = 0L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This enum defines all possibilities for handling
|
* This enum defines all possibilities for handling
|
||||||
* {@link GroupResizeEvent}s.<br>
|
* {@link GroupResizeEvent}s.<br>
|
||||||
* These can be: {@link OperationType#ADD} or {@link OperationType#REMOVE}.<br>
|
* These can be: {@link Operation#ADD} or {@link Operation#REMOVE}.<br>
|
||||||
* <br>
|
* <br>
|
||||||
* Project: <strong>envoy-common</strong><br>
|
* Project: <strong>envoy-common</strong><br>
|
||||||
* File: <strong>GroupResizeEvent.java</strong><br>
|
* File: <strong>GroupResizeEvent.java</strong><br>
|
||||||
@ -36,7 +36,7 @@ public class GroupResizeEvent extends Event<Long> {
|
|||||||
* @author Leon Hofmeister
|
* @author Leon Hofmeister
|
||||||
* @since Envoy Common v0.1-beta
|
* @since Envoy Common v0.1-beta
|
||||||
*/
|
*/
|
||||||
public enum OperationType {
|
public enum Operation {
|
||||||
/**
|
/**
|
||||||
* Select this element, if the given {@link User} should be added to the given
|
* Select this element, if the given {@link User} should be added to the given
|
||||||
* {@link Group}
|
* {@link Group}
|
||||||
@ -55,43 +55,42 @@ public class GroupResizeEvent extends Event<Long> {
|
|||||||
*
|
*
|
||||||
* @param user the {@link User} who wants to join or leave a group
|
* @param user the {@link User} who wants to join or leave a group
|
||||||
* @param group the {@link Group} he wants to join or leave
|
* @param group the {@link Group} he wants to join or leave
|
||||||
* @param operationType whether the user should be removed from this group. If
|
* @param operation whether the user should be removed from this group. If
|
||||||
* false,
|
* false, this user will be added.
|
||||||
* this user will be added
|
|
||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public GroupResizeEvent(User user, Group group, OperationType operationType) {
|
public GroupResizeEvent(User user, Group group, Operation operation) {
|
||||||
super(user.getID());
|
super(user.getID());
|
||||||
if (group.getMemberIDs().contains(user.getID())) {
|
if (group.getMemberIDs().contains(user.getID())) {
|
||||||
if (operationType.equals(OperationType.ADD)) throw new IllegalStateException(
|
if (operation.equals(Operation.ADD)) throw new IllegalStateException(
|
||||||
"Cannot add " + user + " to group " + group.getID() + " because he is already a member of this group");
|
"Cannot add " + user + " to group " + group.getID() + " because he is already a member of this group");
|
||||||
} else if (operationType.equals(OperationType.REMOVE))
|
} else if (operation.equals(Operation.REMOVE))
|
||||||
throw new IllegalStateException("Cannot remove " + user + " from group " + group.getID() + " because he is no part of this group");
|
throw new IllegalStateException("Cannot remove " + user + " from group " + group.getID() + " because he is no part of this group");
|
||||||
groupID = group.getID();
|
groupID = group.getID();
|
||||||
this.operationType = operationType;
|
this.operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the ID of the {@link Contact} this event is related to
|
* @return the ID of the {@link Contact} this event is related to
|
||||||
* @since Envoy Common v0.2-alpha
|
* @since Envoy Common v0.2-alpha
|
||||||
*/
|
*/
|
||||||
public long getGroupId() { return groupID; }
|
public long getGroupID() { return groupID; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the operationType
|
* @return the operationType
|
||||||
* @since Envoy Common v0.1-beta
|
* @since Envoy Common v0.1-beta
|
||||||
*/
|
*/
|
||||||
public OperationType getOperationType() { return operationType; }
|
public Operation getOperationType() { return operation; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param operationType the operationType to set
|
* @param operation the operationType to set
|
||||||
* @since Envoy Common v0.1-beta
|
* @since Envoy Common v0.1-beta
|
||||||
*/
|
*/
|
||||||
public void setOperationType(OperationType operationType) { this.operationType = operationType; }
|
public void setOperationType(Operation operation) { this.operation = operation; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() { return String.format("GroupResizeEvent[userid=%d,groupid=%d,operationType=%b]", get(), groupID, operationType); }
|
public String toString() { return String.format("GroupResizeEvent[userid=%d,groupid=%d,operation=%b]", get(), groupID, operation); }
|
||||||
}
|
}
|
||||||
|
@ -16,9 +16,10 @@ import envoy.data.Contact;
|
|||||||
*/
|
*/
|
||||||
public class NameChangeEvent extends Event<String> {
|
public class NameChangeEvent extends Event<String> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 0L;
|
|
||||||
private final long id;
|
private final long id;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 0L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link NameChangeEvent} for a user or a group.
|
* Creates a new {@link NameChangeEvent} for a user or a group.
|
||||||
*
|
*
|
||||||
@ -48,5 +49,4 @@ public class NameChangeEvent extends Event<String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() { return String.format("NameChangeEvent[id=%d,name=%s]", id, value); }
|
public String toString() { return String.format("NameChangeEvent[id=%d,name=%s]", id, value); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user