class AbstractExhaustibleResource implements ResourceType {

  @Override
  public Resource aggregate(Resource resourceA, Resource resourceB) {
    checkResource(resourceA);
    checkResource(resourceB);

    if (resourceA.getAmount() == -1 || resourceB.getAmount() == -1) {
      return new ResourceImpl(getId(), -1, getDefaultUnit());
    }

    return new ResourceImpl(
        getId(), resourceA.getAmount() + resourceB.getAmount(), getDefaultUnit());
  }

}