Skip to content

Instantly share code, notes, and snippets.

@mttjj
Created July 16, 2019 18:23
Show Gist options
  • Save mttjj/ad733b7b8394e45889d38d173c8c04b0 to your computer and use it in GitHub Desktop.
Save mttjj/ad733b7b8394e45889d38d173c8c04b0 to your computer and use it in GitHub Desktop.
public class Snippet
{
public static void main(String[] args)
{
Project p = getById(Project.class, 0);
System.out.println(p);
System.out.println(getById(Project.class, 1));
}
private static <T extends Insertable> T getById(Class type, int id)
{
return (T) new Project();
}
private static class Project implements Insertable
{
@Override
public String toString()
{
StringBuilder result = new StringBuilder();
result.append("Hello");
return result.toString();
}
}
interface Insertable
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment