Skip to content

Instantly share code, notes, and snippets.

@ryantheleach
Created May 2, 2015 15:47
Show Gist options
  • Save ryantheleach/9cba877e77cd39505cdd to your computer and use it in GitHub Desktop.
Save ryantheleach/9cba877e77cd39505cdd to your computer and use it in GitHub Desktop.
@Override
public Optional<HungerOverrideData> fill(DataHolder dataHolder, DataPriority overlap) {
HungerOverrideData man = new HungerOverrideData(this);
HungerOverrideData hold = dataHolder.getData(HungerOverrideData.class).orNull();
HungerOverrideData out = null;
switch (overlap){
case DATA_HOLDER:
out = hold;
break;
case DATA_MANIPULATOR:
out = man;
//fallthrough
case PRE_MERGE:
out = man;
if(dataHolder.getData(HungerOverrideData.class).isPresent()){
out.amount =+ hold.amount;
}
break;
case POST_MERGE:
out = hold;
out.amount =+ man.amount;
break;
}
return Optional.of(out);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment