Skip to content

Instantly share code, notes, and snippets.

@stijnvanbael
Last active December 17, 2015 15:59
Show Gist options
  • Save stijnvanbael/5635378 to your computer and use it in GitHub Desktop.
Save stijnvanbael/5635378 to your computer and use it in GitHub Desktop.
Sealed class hieararchy "implementation"
public final class DefaultSealedServices extends SealedServices {
private FooService fooService;
private BarService barService;
// We don’t want the client to instantiate this class
DefaultSealedServices(FooService fooService, BarService barService) {
this.fooService = fooService;
this.barService = barService;
}
@Override
public FooService getFooService() {
return fooService;
}
@Override
public BarService getBarService() {
return barService;
}
@Override
void validate() {
Validate.notNull(this.fooService);
Validate.notNull(this.barService);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment