001/** 002 * Copyright 2013 John Ericksen 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.androidtransfuse.analysis.astAnalyzer; 017 018import org.androidtransfuse.adapter.ASTType; 019import org.apache.commons.lang.builder.EqualsBuilder; 020 021/** 022 * Aspect representing an extra parameter required by a Component. This will trigger the code generator to 023 * build an IntentFactoryStrategy containing the appropriate extras in the constructor or setters. 024 * 025 * @author John Ericksen 026 */ 027public class IntentFactoryExtraAspect implements Comparable<IntentFactoryExtraAspect> { 028 029 private final boolean required; 030 private final String name; 031 private final ASTType type; 032 033 public IntentFactoryExtraAspect(boolean required, String name, ASTType type) { 034 this.required = required; 035 this.name = name; 036 this.type = type; 037 } 038 039 public boolean isRequired() { 040 return required; 041 } 042 043 public String getName() { 044 return name; 045 } 046 047 public ASTType getType() { 048 return type; 049 } 050 051 @Override 052 public boolean equals(Object obj) { 053 if (!(obj instanceof IntentFactoryExtraAspect)) { 054 return false; 055 } 056 if (this == obj) { 057 return true; 058 } 059 IntentFactoryExtraAspect rhs = (IntentFactoryExtraAspect) obj; 060 return new EqualsBuilder() 061 .append(name, rhs.name) 062 .isEquals(); 063 } 064 065 @Override 066 public int hashCode() { 067 return name.hashCode(); 068 } 069 070 @Override 071 public int compareTo(IntentFactoryExtraAspect intentFactoryExtra) { 072 return getName().compareTo(intentFactoryExtra.getName()); 073 } 074}