Created
November 8, 2012 01:52
-
-
Save anonymous/4035987 to your computer and use it in GitHub Desktop.
This file contains 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 com.flurry.example; | |
public interface IBar { | |
public abstract String getName(); | |
} | |
public interface IFoo { | |
public boolean isTransient(); | |
} | |
public abstract class AFoo implements IFoo | |
{ | |
private long fId; | |
public long getId() | |
{ | |
return fId; | |
} | |
@Override | |
public boolean isTransient() | |
{ | |
return fId == 0; | |
} | |
} | |
public class Thing extends AFoo implements IBar | |
{ | |
@Override | |
public String getName() { | |
return "Thing"; | |
} | |
} | |
public abstract class Parameterized<T extends AFoo & IBar> { | |
public final String name; | |
public final static Map<String, Parameterized<?>> entities = new HashMap<String,Parameterized<?>>(); | |
public abstract List<T> getByType(); | |
private Parameterized(String name) { | |
this.name = name; | |
entities.put(name, this); | |
} | |
public static final Parameterized<Thing> THING = new Parameterized<Thing>("thing") { | |
@Override | |
public List<Thing> getByType() { | |
return new ArrayList<Thing>(); | |
} | |
}; | |
} | |
public class CompileMe<T extends AFoo & IBar> { | |
private Parameterized<T> parameterized; | |
public void doSomething() throws Exception { | |
for (T entity : parameterized.getByType()) { | |
if (parameterized == Parameterized.THING) | |
{ | |
System.out.println(entity.getId()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment