001    /*
002     * Copyright (C) 2014 XStream Committers.
003     * All rights reserved.
004     *
005     * Created on 09. January 2014 by Joerg Schaible
006     */
007    package com.thoughtworks.xstream.security;
008    
009    import com.thoughtworks.xstream.core.util.Primitives;
010    
011    /**
012     * Permission for any primitive type and its boxed counterpart (incl. void).
013     * 
014     * @author Jörg Schaible
015     * @since 1.4.7
016     */
017    public class PrimitiveTypePermission implements TypePermission {
018        /**
019         * @since 1.4.7
020         */
021        public static final TypePermission PRIMITIVES = new PrimitiveTypePermission();
022    
023        public boolean allows(Class type) {
024            return type != null && type.isPrimitive() || Primitives.isBoxed(type);
025        }
026    
027        public int hashCode() {
028            return 7;
029        }
030    
031        public boolean equals(Object obj) {
032            return obj != null && obj.getClass() == PrimitiveTypePermission.class;
033        }
034    }