-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FORGE-1248] Redesign parser generics API: permit management of type …
…variable bounds
- Loading branch information
Showing
16 changed files
with
469 additions
and
83 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,5 +36,4 @@ public interface Type<O extends JavaType<O>> extends Origin<O> | |
|
||
public abstract boolean isWildcard(); | ||
|
||
|
||
} |
28 changes: 28 additions & 0 deletions
28
api/src/main/java/org/jboss/forge/parser/java/TypeVariable.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,28 @@ | ||
/* | ||
* Copyright 2012 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.jboss.forge.parser.java; | ||
|
||
import java.util.List; | ||
|
||
import org.jboss.forge.parser.Internal; | ||
import org.jboss.forge.parser.Origin; | ||
|
||
/** | ||
* Represents a type variable of a {@link GenericCapable} {@link JavaType}. | ||
* | ||
* @author mbenson | ||
* | ||
*/ | ||
public interface TypeVariable<O extends JavaType<O>> extends Named, Internal, Origin<O> | ||
{ | ||
/** | ||
* Get the upper bounds of this type variable. | ||
* | ||
* @return (possibly empty) Type[] | ||
*/ | ||
List<Type<O>> getBounds(); | ||
} |
37 changes: 27 additions & 10 deletions
37
api/src/main/java/org/jboss/forge/parser/java/source/GenericCapableSource.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 |
---|---|---|
@@ -1,28 +1,45 @@ | ||
package org.jboss.forge.parser.java.source; | ||
|
||
import java.util.List; | ||
|
||
import org.jboss.forge.parser.java.GenericCapable; | ||
import org.jboss.forge.parser.java.TypeVariable; | ||
|
||
/** | ||
* Represents a Java source element that may define type variables. | ||
* | ||
* @author mbenson | ||
* | ||
* | ||
*/ | ||
public interface GenericCapableSource<T> extends GenericCapable | ||
public interface GenericCapableSource<O extends JavaSource<O>, T> extends | ||
GenericCapable<O> | ||
{ | ||
@Override | ||
List<TypeVariableSource<O>> getTypeVariables(); | ||
|
||
@Override | ||
TypeVariableSource<O> getTypeVariable(String name); | ||
|
||
/** | ||
* Adds a type variable. | ||
* | ||
* @return {@link TypeVariableSource} | ||
*/ | ||
TypeVariableSource<O> addTypeVariable(); | ||
|
||
/** | ||
* Adds a generic type | ||
* Removes a type variable. | ||
* | ||
* @param genericType should never be null | ||
* @return | ||
* @param name should never be null | ||
* @return this | ||
*/ | ||
T addGenericType(String genericType); | ||
T removeTypeVariable(String name); | ||
|
||
/** | ||
* Removes a generic type | ||
* Removes a type variable. | ||
* | ||
* @param genericType should never be null | ||
* @return | ||
* @param typeVariable should never be null | ||
* @return this | ||
*/ | ||
T removeGenericType(String genericType); | ||
T removeTypeVariable(TypeVariable<?> typeVariable); | ||
} |
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
51 changes: 51 additions & 0 deletions
51
api/src/main/java/org/jboss/forge/parser/java/source/TypeVariableSource.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,51 @@ | ||
/* | ||
* Copyright 2012 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.jboss.forge.parser.java.source; | ||
|
||
import org.jboss.forge.parser.java.JavaType; | ||
import org.jboss.forge.parser.java.TypeVariable; | ||
|
||
/** | ||
* Represents a type variable of a {@link GenericCapableSource} {@link JavaSource}. | ||
* | ||
* @author mbenson | ||
* | ||
*/ | ||
public interface TypeVariableSource<O extends JavaSource<O>> extends TypeVariable<O>, | ||
NamedSource<TypeVariableSource<O>> | ||
{ | ||
/** | ||
* Set the bounds of this type variable. | ||
* | ||
* @param bounds | ||
* @return this | ||
*/ | ||
TypeVariableSource<O> setBounds(JavaType<?>... bounds); | ||
|
||
/** | ||
* Set the bounds of this type variable. | ||
* | ||
* @param bounds | ||
* @return this | ||
*/ | ||
TypeVariableSource<O> setBounds(Class<?>... bounds); | ||
|
||
/** | ||
* Set the bounds of this type variable. | ||
* | ||
* @param bounds | ||
* @return this | ||
*/ | ||
TypeVariableSource<O> setBounds(String... bounds); | ||
|
||
/** | ||
* Remove any bounds declared on this type variable. | ||
* | ||
* @return this | ||
*/ | ||
TypeVariableSource<O> removeBounds(); | ||
} |
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
Oops, something went wrong.