-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#48 Introduce ObjectIdentifier into the contexts
- Create ObjectIdentifier (initial version) - Shorten context names - Remove generic info from context
- Loading branch information
Showing
38 changed files
with
321 additions
and
298 deletions.
There are no files selected for viewing
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
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
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
54 changes: 0 additions & 54 deletions
54
injector/src/main/java/ch/jalu/injector/context/InstantiationContext.java
This file was deleted.
Oops, something went wrong.
48 changes: 48 additions & 0 deletions
48
injector/src/main/java/ch/jalu/injector/context/ObjectContext.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,48 @@ | ||
package ch.jalu.injector.context; | ||
|
||
import ch.jalu.injector.Injector; | ||
|
||
/** | ||
* Context of instantiation. | ||
*/ | ||
public abstract class ObjectContext { | ||
|
||
protected final Injector injector; | ||
protected final ResolutionType resolutionType; | ||
protected final ObjectIdentifier originalIdentifier; | ||
protected ObjectIdentifier identifier; | ||
|
||
public ObjectContext(Injector injector, ResolutionType resolutionType, ObjectIdentifier objectIdentifier) { | ||
this(injector, resolutionType, objectIdentifier, objectIdentifier); | ||
} | ||
|
||
public ObjectContext(Injector injector, ResolutionType resolutionType, ObjectIdentifier originalIdentifier, | ||
ObjectIdentifier identifier) { | ||
this.injector = injector; | ||
this.resolutionType = resolutionType; | ||
this.originalIdentifier = originalIdentifier; | ||
this.identifier = identifier; | ||
} | ||
|
||
/** | ||
* @return the injector | ||
*/ | ||
public Injector getInjector() { | ||
return injector; | ||
} | ||
|
||
/** | ||
* @return the context in which the object should be instantiated | ||
*/ | ||
public ResolutionType getResolutionType() { | ||
return resolutionType; | ||
} | ||
|
||
public ObjectIdentifier getOriginalIdentifier() { | ||
return originalIdentifier; | ||
} | ||
|
||
public ObjectIdentifier getIdentifier() { | ||
return identifier; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
injector/src/main/java/ch/jalu/injector/context/ObjectIdentifier.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,27 @@ | ||
package ch.jalu.injector.context; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* Identifies objects. | ||
*/ | ||
public class ObjectIdentifier { | ||
|
||
private final Class<?> type; | ||
private final List<Annotation> annotations; | ||
|
||
public ObjectIdentifier(Class<?> type, Annotation... annotations) { | ||
this.type = type; | ||
this.annotations = Arrays.asList(annotations); | ||
} | ||
|
||
public Class<?> getType() { | ||
return type; | ||
} | ||
|
||
public List<Annotation> getAnnotations() { | ||
return annotations; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
injector/src/main/java/ch/jalu/injector/context/ResolvedContext.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,37 @@ | ||
package ch.jalu.injector.context; | ||
|
||
import ch.jalu.injector.Injector; | ||
import ch.jalu.injector.handlers.instantiation.Instantiation; | ||
|
||
/** | ||
* Instantiation context after the class has been resolved, i.e. it is known what | ||
* instantiation method is used for it. | ||
*/ | ||
public class ResolvedContext extends ObjectContext { | ||
|
||
private final Instantiation<?> instantiation; | ||
|
||
/** | ||
* Constructor. | ||
* <p> | ||
* The type of {@link #identifier} and {@link #instantiation} should be identical. | ||
* | ||
* @param injector the injector | ||
* @param resolutionType the resolution type | ||
* @param originalIdentifier the class that was originally requested | ||
* @param identifier the class that was mapped to be instantiated | ||
* @param instantiation the instantiation method | ||
*/ | ||
public ResolvedContext(Injector injector, ResolutionType resolutionType, ObjectIdentifier originalIdentifier, | ||
ObjectIdentifier identifier, Instantiation<?> instantiation) { | ||
super(injector, resolutionType, originalIdentifier, identifier); | ||
this.instantiation = instantiation; | ||
} | ||
|
||
/** | ||
* @return the instantiation method with which the object should be created | ||
*/ | ||
public Instantiation<?> getInstantiation() { | ||
return instantiation; | ||
} | ||
} |
37 changes: 0 additions & 37 deletions
37
injector/src/main/java/ch/jalu/injector/context/ResolvedInstantiationContext.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.