Created
July 11, 2014 11:24
-
-
Save rozza/d073094294eb7ce3d85b to your computer and use it in GitHub Desktop.
Abstract class with a static member that can't be called
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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