public CompiledShape( TCharObjectMap<ItemStack> match, String... lines ) { match.putIfAbsent( '0', null ); char[][] array = new char[ lines.length ][]; int lastLength = -1; for( int i = 0; i < lines.length; i++ ) { array[ i ] = lines[ i ].toCharArray(); if( lastLength != -1 && lastLength != lines[ i ].length() ) { throw new IllegalArgumentException( "Not equal length of lines" ); } lastLength = lines[ i ].length(); for( char c : lines[ i ].toCharArray() ) { if( !match.containsKey( c ) ) { throw new IllegalArgumentException( "Invalid char " + c ); } } } this.shape = new ItemStack[ array.length ][]; for( int i = 0; i < array.length; i++ ) { char[] b = array[ i ]; ItemStack[] r = new ItemStack[ b.length ]; for( int k = 0; k < r.length; k++ ) { r[ k ] = match.get( b[ k ] ); } shape[ i ] = r; } }
/** {@inheritDoc} */ public boolean equals( Object other ) { if ( ! ( other instanceof TCharObjectMap ) ) { return false; } TCharObjectMap that = ( TCharObjectMap ) other; if ( that.size() != this.size() ) { return false; } try { TCharObjectIterator iter = this.iterator(); while ( iter.hasNext() ) { iter.advance(); char key = iter.key(); Object value = iter.value(); if ( value == null ) { if ( !( that.get( key ) == null && that.containsKey( key ) ) ) { return false; } } else { if ( !value.equals( that.get( key ) ) ) { return false; } } } } catch ( ClassCastException ex ) { // unused. } return true; }
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // MAP //noinspection unchecked _map = ( TCharObjectMap<V> ) in.readObject(); }
/** {@inheritDoc} */ @Override @SuppressWarnings("rawtypes") public boolean equals( Object other ) { if ( ! ( other instanceof TCharObjectMap ) ) { return false; } TCharObjectMap that = ( TCharObjectMap ) other; if ( that.size() != this.size() ) { return false; } try { TCharObjectIterator iter = this.iterator(); while ( iter.hasNext() ) { iter.advance(); char key = iter.key(); Object value = iter.value(); if ( value == null ) { if ( !( that.get( key ) == null && that.containsKey( key ) ) ) { return false; } } else { if ( !value.equals( that.get( key ) ) ) { return false; } } } } catch ( ClassCastException ex ) { // unused. } return true; }
@Override @SuppressWarnings("unchecked") public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException { // VERSION in.readByte(); // MAP //noinspection unchecked _map = ( TCharObjectMap<V> ) in.readObject(); }
/** {@inheritDoc} */ public void putAll( TCharObjectMap<? extends V> map ){ map.forEachEntry( PUT_ALL_PROC ); }
/** {@inheritDoc} */ @Override public void putAll( TCharObjectMap<? extends V> map ){ map.forEachEntry( PUT_ALL_PROC ); }
/** {@inheritDoc} */ public void putAll( TCharObjectMap<V> map ){ map.forEachEntry( PUT_ALL_PROC ); }
/** * Creates a new <code>TCharObjectHashMap</code> that contains the entries * in the map passed to it. * * @param map the <tt>TCharObjectMap</tt> to be copied. */ public TCharObjectHashMap( TCharObjectMap<? extends V> map ) { this( map.size(), 0.5f, map.getNoEntryKey() ); putAll( map ); }
/** * Creates a wrapper that decorates the specified primitive map. * * @param map the <tt>TCharObjectMap</tt> to wrap. */ public TCharObjectMapDecorator( TCharObjectMap<V> map ) { super(); this._map = map; }
/** * Returns a reference to the map wrapped by this decorator. * * @return the wrapped <tt>TCharObjectMap</tt> instance. */ public TCharObjectMap<V> getMap() { return _map; }
@Override public void putAll(TCharObjectMap map) { }