Skip to content

Instantly share code, notes, and snippets.

@rozza
Created July 11, 2014 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rozza/d073094294eb7ce3d85b to your computer and use it in GitHub Desktop.
Save rozza/d073094294eb7ce3d85b to your computer and use it in GitHub Desktop.
Abstract class with a static member that can't be called
package org.example;
public abstract class SomeAbstractClass {
SomeAbstractClass(){}
/**
* The name of the SomeAbstractClass instance.
*
* @return the name
*/
public abstract String getName();
/**
* Concrete Implementation of SomeAbstractClass
*/
private static final class SomeConcreteClass extends SomeAbstractClass {
private SomeConcreteClass() {
}
@Override
public String getName() {
return "Concrete";
}
}
/**
* @return SomeAbstractClass
*/
public static SomeAbstractClass concrete() {
return CONCRETE;
}
private static final SomeAbstractClass CONCRETE;
static {
CONCRETE = new SomeConcreteClass();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment