001 /* 002 * Licensed under the Apache License, Version 2.0 (the "License"); 003 * you may not use this file except in compliance with the License. 004 * You may obtain a copy of the License at 005 * 006 * http://www.apache.org/licenses/LICENSE-2.0 007 * 008 * Unless required by applicable law or agreed to in writing, software 009 * distributed under the License is distributed on an "AS IS" BASIS, 010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 011 * See the License for the specific language governing permissions and 012 * limitations under the License. 013 */ 014 package org.apache.commons.classscan.builtin; 015 016 import java.util.Collections; 017 import java.util.Set; 018 019 import org.apache.commons.classscan.MetaClassPathElement; 020 import org.apache.commons.classscan.model.MetaAnnotation; 021 import org.apache.commons.classscan.model.MetaClass; 022 import org.apache.commons.classscan.model.MetaField; 023 import org.apache.commons.classscan.model.MetaMethod; 024 import org.apache.commons.classscan.spi.model.SpiMetaClass; 025 import org.apache.commons.classscan.spi.model.SpiMetaClassLoader; 026 027 public enum PrimitiveClass implements SpiMetaClass { 028 029 B(Byte.TYPE, Byte.class), 030 C(Character.TYPE, Character.class), 031 D(Double.TYPE, Double.class), 032 F(Float.TYPE, Float.class), 033 I(Integer.TYPE, Integer.class), 034 J(Long.TYPE, Long.class), 035 S(Short.TYPE, Short.class), 036 Z(Boolean.TYPE, Boolean.class), 037 V(Void.TYPE, Void.class); 038 039 private final String primitiveName; 040 private final String wrapperName; 041 042 PrimitiveClass(Class<?> typeClass, Class<?> wrapperClass) { 043 primitiveName= typeClass.getCanonicalName(); 044 wrapperName= wrapperClass.getCanonicalName(); 045 } 046 047 @Override 048 public MetaClassPathElement getClassLocation() { 049 return null; 050 } 051 052 @Override 053 public String getName() { 054 return primitiveName; 055 } 056 057 @Override 058 public MetaClass getParent() { 059 return null; 060 } 061 062 @Override 063 public Set<MetaClass> getInterfaces() { 064 return Collections.emptySet(); 065 } 066 067 @Override 068 public Set<? extends MetaAnnotation> getAnnotations() { 069 return Collections.emptySet(); 070 } 071 072 @Override 073 public MetaAnnotation getAnnotation(String annotationName) { 074 return null; 075 } 076 077 @Override 078 public Set<MetaMethod> getMethods() { 079 return Collections.emptySet(); 080 } 081 082 @Override 083 public Set<MetaField> getFields() { 084 return Collections.emptySet(); 085 } 086 087 @Override 088 public boolean isAssignableFrom(MetaClass assignor) { 089 return equals(assignor) || assignor.getName().equals(wrapperName); 090 } 091 092 @Override 093 public boolean resolve(SpiMetaClassLoader classLoader) { 094 return true; 095 } 096 }