001    package org.apache.archiva.admin.model.beans;
002    /*
003     * Licensed to the Apache Software Foundation (ASF) under one
004     * or more contributor license agreements.  See the NOTICE file
005     * distributed with this work for additional information
006     * regarding copyright ownership.  The ASF licenses this file
007     * to you under the Apache License, Version 2.0 (the
008     * "License"); you may not use this file except in compliance
009     * with the License.  You may obtain a copy of the License at
010     *
011     *   http://www.apache.org/licenses/LICENSE-2.0
012     *
013     * Unless required by applicable law or agreed to in writing,
014     * software distributed under the License is distributed on an
015     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016     * KIND, either express or implied.  See the License for the
017     * specific language governing permissions and limitations
018     * under the License.
019     */
020    
021    import javax.xml.bind.annotation.XmlRootElement;
022    import java.io.Serializable;
023    import java.util.ArrayList;
024    import java.util.List;
025    
026    /**
027     * @author Olivier Lamy
028     * @since 1.4-M1
029     */
030    @XmlRootElement( name = "fileType" )
031    public class FileType
032        implements Serializable
033    {
034        /**
035         * Field id.
036         */
037        private String id;
038    
039        /**
040         * Field patterns.
041         */
042        private List<String> patterns;
043    
044        public FileType()
045        {
046            // no op
047        }
048    
049        public FileType( String id, List<String> patterns )
050        {
051            this.id = id;
052            this.patterns = patterns;
053        }
054    
055        public String getId()
056        {
057            return id;
058        }
059    
060        public void setId( String id )
061        {
062            this.id = id;
063        }
064    
065        public List<String> getPatterns()
066        {
067            if ( patterns == null )
068            {
069                this.patterns = new ArrayList<String>( 0 );
070            }
071            return patterns;
072        }
073    
074        public void setPatterns( List<String> patterns )
075        {
076            this.patterns = patterns;
077        }
078    
079        public void addPattern( String pattern )
080        {
081            getPatterns().add( pattern );
082        }
083    
084        public void removePattern( String pattern )
085        {
086            getPatterns().remove( pattern );
087        }
088    
089        @Override
090        public boolean equals( Object o )
091        {
092            if ( this == o )
093            {
094                return true;
095            }
096            if ( o == null || getClass() != o.getClass() )
097            {
098                return false;
099            }
100    
101            FileType fileType = (FileType) o;
102    
103            if ( id != null ? !id.equals( fileType.id ) : fileType.id != null )
104            {
105                return false;
106            }
107    
108            return true;
109        }
110    
111        @Override
112        public int hashCode()
113        {
114            return id != null ? 37 + id.hashCode() : 0;
115        }
116    
117        @Override
118        public String toString()
119        {
120            final StringBuilder sb = new StringBuilder();
121            sb.append( "FileType" );
122            sb.append( "{id='" ).append( id ).append( '\'' );
123            sb.append( ", patterns=" ).append( patterns );
124            sb.append( '}' );
125            return sb.toString();
126        }
127    }