001package org.apache.archiva.redback.rest.api.model; 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 021import io.swagger.v3.oas.annotations.media.Schema; 022 023import javax.xml.bind.annotation.XmlRootElement; 024import java.io.Serializable; 025import java.util.Collection; 026import java.util.List; 027 028/** 029 * @author Olivier Lamy 030 * @since 2.1 031 */ 032@XmlRootElement(name = "groupMapping") 033@Schema(name="GroupMapping", description = "List of Group to Role mappings") 034public class GroupMapping 035 implements Serializable 036{ 037 private String group; 038 039 private List<String> roleNames; 040 041 public GroupMapping() 042 { 043 // no op 044 } 045 046 public GroupMapping( String group, List<String> roleNames ) 047 { 048 this.group = group; 049 this.roleNames = roleNames; 050 } 051 052 @Schema(description = "The group name that is mapped") 053 public String getGroup() 054 { 055 return group; 056 } 057 058 public void setGroup( String group ) 059 { 060 this.group = group; 061 } 062 063 @Schema(description = "The list of roles that are mapped to this group") 064 public Collection<String> getRoleNames() 065 { 066 return roleNames; 067 } 068 069 public void setRoleNames( List<String> roleNames ) 070 { 071 this.roleNames = roleNames; 072 } 073 074 @Override 075 public String toString() 076 { 077 final StringBuilder sb = new StringBuilder(); 078 sb.append( "LdapGroupMapping" ); 079 sb.append( "{group='" ).append( group ).append( '\'' ); 080 sb.append( ", roleNames=" ).append( roleNames ); 081 sb.append( '}' ); 082 return sb.toString(); 083 } 084 085 @Override 086 public boolean equals( Object o ) 087 { 088 if ( this == o ) 089 { 090 return true; 091 } 092 if ( o == null || getClass() != o.getClass() ) 093 { 094 return false; 095 } 096 097 GroupMapping that = (GroupMapping) o; 098 099 if ( !group.equals( that.group ) ) 100 { 101 return false; 102 } 103 104 return true; 105 } 106 107 @Override 108 public int hashCode() 109 { 110 return group.hashCode(); 111 } 112}