Skip to content

Benchmarks Patterns

Marcelo Sousa edited this page May 6, 2015 · 3 revisions
  1. Throw unsupported operations exceptions
  • AbstractAspectJAdvisorFactoryTests: public int compareTo(Object arg0) {throw new UnsupportedOperationException();}
  • AbstractMemoryHttpDataTest: public int compareTo(InterfaceHttpData o) {throw new UnsupportedOperationException("Should never be called.");}
  1. Empty method definition
  • AccountModel: public int compareTo(com.liferay.portal.model.Account account);
  • AddressModel: public int compareTo(com.liferay.portal.model.Address address);
  1. Call to other comparators (fields, other classes, related to abstract classes?)
  • AbstractByteBuf: public int compareTo(ByteBuf that) {return ByteBufUtil.compare(this, that);} (We have ByteBuf)
  • AbstractChannelBuffer: public int compareTo(ChannelBuffer that) {return ChannelBuffers.compare(this, that);}
  • AbstractHandlerMethodMapping: public int compare(Match match1, Match match2) {return this.comparator.compare(match1.mapping, match2.mapping);}
  • AbstractMemoryHttpDataTest: same as AbstractHandlerMethodMapping
  • AbstractMediaTypeExpression: public int compareTo(AbstractMediaTypeExpression other) {return MediaType.SPECIFICITY_COMPARATOR.compare(this.getMediaType(), other.getMediaType());}
  • AbstractQueueSorterImpl:
  • AccountWrapper: public int compareTo(com.liferay.portal.model.Account account) { return _account.compareTo(account); }
  • ActionComparator:
  • AddressableNode: public int compareTo(AddressableNode node) {return this.address.compareTo(node.address);}
  • AddressWrapper:
  1. Implement comparator based on fields
  • AccountModelImpl:
  • ActivityChooserModel:
  • ActivityManagerService:
  • AddressModelImpl:
  1. Check for equality via address and then call other comparators of specific fields
  • AbstractChannel (int): public final int compareTo(Channel o) {if (this == o) {return 0;} return id().compareTo(o.id());}
  1. Check for null (ret -1 does not seem correct.) and then call field comparators
  • AbstractConfigurator (Strings): public int compareTo(Configurator o) {if (o == null) {return -1;} return getUrl().getHost().compareTo(o.getUrl().getHost());}
  1. Check for equality via address, use hashCode to compare and other comparators
  • AbstractConstant:
  1. Call comparators of Strings (fields or via toString)
  • AbstractConfigurator:
  • AbstractFieldMapper: public int compare(Mapper o1, Mapper o2) {return o1.name().compareTo(o2.name());}
  1. Simple comparators (integer, long comparators)
  • AbstractProject: public int compare(Integer o1, Integer o2) {return o2-o1;}
  • AbstractQueueSorterImpl:
  • ActionFilters:
  1. Call comparators of Integers
  • AC: public int compareTo(Ac ac) {return this.getPriority()-ac.getPriority();}
  • AccessPointControllerImpl: public int compare(AccessPoint lhs, AccessPoint rhs) {return -Integer.compare(score(lhs), score(rhs));}
  1. Complex comparators (equality via address, null, field comparators, for loops, etc.)
  • AccountManagerServiceTest:
  • ActivateComparator:
Clone this wiki locally