/** * Compares the specified object with this command for equality. The comparison is based on class * and name only. * * @param obj Object to be compared with this command. * @return <code>true</code> if the specified object is equal to this command */ @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || this.getClass() != obj.getClass()) return false; final Command command = (Command) obj; return name.equals(command.getName()); }
static { // initialize the get commands getCommands.put(GET_FOLDERS.getName(), GET_FOLDERS); getCommands.put(GET_FOLDERS_AND_FILES.getName(), GET_FOLDERS_AND_FILES); getCommands.put(CREATE_FOLDER.getName(), CREATE_FOLDER); // initialize the post commands postCommands.put(FILE_UPLOAD.getName(), FILE_UPLOAD); postCommands.put(QUICK_UPLOAD.getName(), QUICK_UPLOAD); }
/** * Returns the command constant with the specified name. In contrast to {@link #valueOf(String)} * it returns a null instead of throwing an exception if a command constant was not found. * * @param name the name of the constant to return * @return the command constant with the specified name, else <code>null</code> */ public static Command getCommand(final String name) { try { return Command.valueOf(name); } catch (Exception e) { return null; } }