Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FISH-161 HK2 Annotation Parser improvements #12

Merged
merged 9 commits into from
Jul 1, 2020
4 changes: 2 additions & 2 deletions class-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -13,7 +13,6 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.hk2.classmodel.reflect;

import java.util.Collection;
Expand All @@ -26,10 +25,10 @@
public interface ClassModel extends ExtensibleType<ClassModel> {

/**
* Returns an unmodifiable collection of fields models that represent
* all the declared fields of this classes.
* Returns an unmodifiable collection of fields models that represent all
* the declared fields of this classes.
*
* @return collection of declared fields
* @return collection of declared fields
*/
public Collection<FieldModel> getFields();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.hk2.classmodel.reflect;

/**
*
* @author [email protected]
*/
public interface EnumModel {

Type getType();

String getValue();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.hk2.classmodel.reflect;

import java.util.Collection;

/**
*
* @author [email protected]
*/
public interface EnumType extends ExtensibleType<EnumType> {

/**
* Returns an unmodifiable collection of fields models that represent all
* the declared fields of this enum.
*
* @return collection of declared fields
*/
public Collection<FieldModel> getFields();

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -72,4 +72,11 @@ public interface ExtensibleType<T extends ExtensibleType> extends Type {
* @reutrn collection of defined static fields
*/
Collection<FieldModel> getStaticFields();

/**
* Returns the unqualified name of the underlying type.
*
* @return the simple name of class
*/
String getSimpleName();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -21,19 +21,39 @@
*
* @author Jerome Dochez
*/
public interface FieldModel extends Member, AnnotatedElement {
public interface FieldModel extends Member, AnnotatedElement, ParameterizedType {

/**
* Returns the declared type of the field
*
* @return the field type
*/
public ExtensibleType getType();
ExtensibleType getType();

/**
* Returns the declared type name of the field
*
* @return the field type name
*/
String getTypeName();

/**
* Returns the declaring type of this field, which is a class.
*
* @return the field declaring class.
*/
public ExtensibleType getDeclaringType();
ExtensibleType getDeclaringType();

/**
* Returns the declaring type name of this field, which is a class.
*
* @return the field declaring class name.
*/
String getDeclaringTypeName();

/**
*
* @return true, if field is marked transient.
*/
boolean isTransient();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -16,6 +16,8 @@

package org.glassfish.hk2.classmodel.reflect;

import java.util.List;

/**
* Model to represent a method declaration
*/
Expand All @@ -37,11 +39,26 @@ public interface MethodModel extends Member, AnnotatedElement {
* Returns the method return type
* @return the method's return type
*/
String getReturnType();
ParameterizedType getReturnType();

/**
* Returns the parameter types as string
* @return the parameter types
*/
String[] getArgumentTypes();

/**
* Returns the list of parameter
*
* @return the list of parameter
*/
List<Parameter> getParameters();

/**
* Return the parameter by index
*
* @param index
* @return the parameter by index
*/
Parameter getParameter(int index);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -21,7 +21,7 @@
*
* @author Jerome Dochez
*/
public interface Parameter extends AnnotatedElement {
public interface Parameter extends AnnotatedElement, ParameterizedType {

/**
* Parameters of a method are ordered based on the method
Expand All @@ -35,5 +35,12 @@ public interface Parameter extends AnnotatedElement {
* Returns the parameter type
* @return parameter type
*/
public ExtensibleType<?> getType();
public Type getType();

/**
* Returns the parameter index
*
* @return parameter index
*/
public int getIndex();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.hk2.classmodel.reflect;

import java.util.List;

/**
* Denote a Generic type that is parameterized over types
*
* @author [email protected]
*/
public interface ParameterizedType {

Type getType();

String getTypeName();

List<ParameterizedType> getGenericTypes();
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -18,20 +18,20 @@

import org.glassfish.hk2.classmodel.reflect.*;

import java.net.URI;
import java.util.*;

/**
* Implementation of a class model
*/
public class ClassModelImpl extends ExtensibleTypeImpl<ClassModel> implements ClassModel {

final List<FieldModel> fields = new ArrayList<FieldModel > ();
final List<FieldModel> fields = new ArrayList<>();

public ClassModelImpl(String name, TypeProxy<Type> sink, TypeProxy parent) {
super(name, sink, parent);
}

@Override
synchronized void addField(FieldModel field) {
fields.add(field);
}
Expand All @@ -50,4 +50,5 @@ protected void print(StringBuffer sb) {
}
sb.append("]");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.glassfish.hk2.classmodel.reflect.impl;

import org.glassfish.hk2.classmodel.reflect.*;

/**
*
* @author [email protected]
*/
public class EnumModelImpl implements EnumModel {

private final Type type;

private final String value;

public EnumModelImpl(Type type, String value) {
this.type = type;
this.value = value;
}

@Override
public Type getType() {
return type;
}

@Override
public String getValue() {
return value;
}

@Override
public String toString() {
return value;
}
}
Loading