Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
codegen: Create models for representing anonymous implementations (#434)
- Loading branch information
Showing
2 changed files
with
106 additions
and
35 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
44 changes: 37 additions & 7 deletions
44
...parent/codegen/src/main/java/com/speedment/common/codegen/model/value/AnonymousValue.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,22 +1,52 @@ | |||
package com.speedment.common.codegen.model.value; | package com.speedment.common.codegen.model.value; | ||
|
|
||
import com.speedment.common.codegen.model.ClassOrInterface; | |||
import com.speedment.common.codegen.model.Value; | import com.speedment.common.codegen.model.Value; | ||
import com.speedment.common.codegen.model.trait.HasGenerics; | import com.speedment.common.codegen.model.trait.HasClasses; | ||
import com.speedment.common.codegen.model.trait.HasFields; | |||
import com.speedment.common.codegen.model.trait.HasInitializers; | |||
import com.speedment.common.codegen.model.trait.HasMethods; | |||
import com.speedment.common.codegen.model.trait.HasValues; | import com.speedment.common.codegen.model.trait.HasValues; | ||
|
|
||
import java.lang.reflect.Type; | |||
import java.util.List; | |||
|
|||
/** | /** | ||
* A value representing a reference to an abstract implementation used | * A value representing a reference to an abstract implementation used | ||
* anonymously to set a field. | * anonymously to set a field. | ||
* | * | ||
* @author Emil Forslund | * @author Emil Forslund | ||
* @since 2.4.6 | * @since 2.4.6 | ||
*/ | */ | ||
public interface AnonymousValue<T extends ClassOrInterface<T>> | public interface AnonymousValue | ||
extends Value<T>, | extends Value<Type>, | ||
HasGenerics<AnonymousValue<T>>, | HasValues<AnonymousValue>, | ||
HasValues<AnonymousValue<T>> { | HasMethods<AnonymousValue>, | ||
HasFields<AnonymousValue>, | |||
HasInitializers<AnonymousValue>, | |||
HasClasses<AnonymousValue> { | |||
|
|
||
@Override | @Override | ||
AnonymousValue<T> setValue(T value); | AnonymousValue setValue(Type value); | ||
|
|||
/** | |||
* Returns a list of type parameters to set when instantiating the anonymous | |||
* type. | |||
* <p> | |||
* The returned list is mutable. | |||
* | |||
* @return list of type parameters | |||
*/ | |||
List<Type> getTypeParameters(); | |||
|
|||
/** | |||
* Adds the specified type parameter to the end of the | |||
* {@link #getTypeParameters} list. | |||
* | |||
* @param typeParameter the type parameter to add | |||
* @return a reference to this | |||
*/ | |||
default AnonymousValue add(Type typeParameter) { | |||
getTypeParameters().add(typeParameter); | |||
return this; | |||
} | |||
} | } |