1 package com.sun.tools.sjavac.pubapi; 2 3 import java.io.Serializable; 4 import java.util.List; 5 import java.util.stream.Collectors; 6 7 public class PubApiTypeParam implements Serializable { 8 9 private static final long serialVersionUID = 8899204612014329162L; 10 11 private final String identifier; 12 private final List<TypeDesc> bounds; 13 14 public PubApiTypeParam(String identifier, List<TypeDesc> bounds) { 15 this.identifier = identifier; 16 this.bounds = bounds; 17 } 18 19 @Override 20 public boolean equals(Object obj) { 21 if (getClass() != obj.getClass()) 22 return false; 23 PubApiTypeParam other = (PubApiTypeParam) obj; 24 return identifier.equals(other.identifier) 25 && bounds.equals(other.bounds); 26 } 27 28 @Override 29 public int hashCode() { 30 return identifier.hashCode() ^ bounds.hashCode(); 31 } 32 33 public String asString() { 34 if (bounds.isEmpty()) 35 return identifier; 36 String boundsStr = bounds.stream() 37 .map(TypeDesc::encodeAsString) 38 .collect(Collectors.joining(" & ")); 39 return identifier + " extends " + boundsStr; 40 } 41 42 @Override 43 public String toString() { 44 return String.format("%s[id: %s, bounds: %s]", 45 getClass().getSimpleName(), 46 identifier, 47 bounds); 48 } 49 }