-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
217. Classes can be instantiated by user defined instantiators.
- Loading branch information
Showing
34 changed files
with
401 additions
and
584 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/main/java/pl/pojo/tester/api/AbstractObjectInstantiator.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package pl.pojo.tester.api; | ||
|
||
/** | ||
* This is a base class for all instantiators. | ||
* | ||
* @author Piotr Joński | ||
* @since 0.8.0 | ||
*/ | ||
public abstract class AbstractObjectInstantiator { | ||
|
||
protected final Class<?> clazz; | ||
|
||
/** | ||
* Creates new instantiator for defined class. | ||
* | ||
* @param clazz class that will be instantiated | ||
*/ | ||
public AbstractObjectInstantiator(final Class<?> clazz) { | ||
this.clazz = clazz; | ||
} | ||
|
||
/** | ||
* Produces new instances of given class. | ||
* | ||
* @return new object that class is defined in constructor. | ||
*/ | ||
public abstract Object instantiate(); | ||
|
||
/** | ||
* @return class defined in constructor. | ||
*/ | ||
public Class<?> getClazz() { | ||
return clazz; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "AbstractObjectInstantiator{clazz=" + clazz + '}'; | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
src/main/java/pl/pojo/tester/internal/instantiator/AbstractInternalInstantiator.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package pl.pojo.tester.internal.instantiator; | ||
|
||
import pl.pojo.tester.api.AbstractObjectInstantiator; | ||
|
||
abstract class AbstractInternalInstantiator extends AbstractObjectInstantiator { | ||
|
||
AbstractInternalInstantiator(final Class<?> clazz) { | ||
super(clazz); | ||
} | ||
|
||
abstract boolean canInstantiate(); | ||
|
||
@Override | ||
public String toString() { | ||
return "AbstractInternalInstantiator{clazz=" + clazz + '}'; | ||
} | ||
} |
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
20 changes: 0 additions & 20 deletions
20
src/main/java/pl/pojo/tester/internal/instantiator/AbstractObjectInstantiator.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.