OSDN Git Service

X.690 Amendment1 (10/2003)
[bm-asn1/bm-asn1.git] / jp / bitmeister / asn1 / type / NamedTypeSpecification.java
index 7011a2c..77b3754 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2011 BitMeister Inc.
+ * Copyright 2011-2012 BitMeister Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -155,9 +155,8 @@ public class NamedTypeSpecification implements
                if (tag != null) {
                        return tagClass == tag.tagClass() && tagNumber == tag.tagNumber();
                }
-               @SuppressWarnings("unchecked")
                TypeSpecification typeSpec = TypeSpecification
-                               .getSpecification((Class<? extends ASN1Type>) field.getType());
+                               .getSpecification(field.getType().asSubclass(ASN1Type.class));
                if (typeSpec.tagged()) {
                        return typeSpec.matches(tagClass, tagNumber);
                }
@@ -169,10 +168,9 @@ public class NamedTypeSpecification implements
         * 
         * @return An empty instance of this element type.
         */
-       @SuppressWarnings("unchecked")
        public ASN1Type instantiate() {
                return ASN1Type
-                               .instantiate((Class<? extends ASN1Type>) field.getType());
+                               .instantiate(field.getType().asSubclass(ASN1Type.class));
        }
 
        /**
@@ -180,9 +178,8 @@ public class NamedTypeSpecification implements
         * 
         * @return The type of this field.
         */
-       @SuppressWarnings("unchecked")
        Class<? extends ASN1Type> type() {
-               return (Class<? extends ASN1Type>) field.getType();
+               return field.getType().asSubclass(ASN1Type.class);
        }
 
        /**
@@ -190,9 +187,8 @@ public class NamedTypeSpecification implements
         * 
         * @return
         */
-       @SuppressWarnings("unchecked")
        Class<? extends ASN1Type> enclosingType() {
-               return (Class<? extends ASN1Type>) field.getDeclaringClass();
+               return field.getDeclaringClass().asSubclass(ASN1Type.class);
        }
 
        /**