test v2
This commit is contained in:
24
V2/snippet V2 PartTypeImpl.txt
Normal file
24
V2/snippet V2 PartTypeImpl.txt
Normal file
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Snippet to add to your PartTypeImpl to support
|
||||
* the V2 API
|
||||
*/
|
||||
public class PartTypeImpl implements PartType {
|
||||
private String name;
|
||||
private Class<? extends PartImpl> classRef;
|
||||
private Category category;
|
||||
public PartTypeImpl(String name, Class<? extends PartImpl> classRef, Category category) {
|
||||
this.name = name;
|
||||
this.classRef = classRef;
|
||||
this.category = category;
|
||||
}
|
||||
public PartImpl newInstance() {
|
||||
Constructor<? extends PartImpl> constructor;
|
||||
try {
|
||||
constructor = classRef.getConstructor();
|
||||
return constructor.newInstance();
|
||||
} catch (Exception e) {
|
||||
Logger.getGlobal().log(Level.SEVERE, "constructor call failed", e);
|
||||
System.exit(-1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user