1 /* 2 * Copyright 2010 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.google.android.testing.mocking; 17 18 /** 19 * Represents the contents of a Class file. 20 * 21 * @author swoodward@google.com (Stephen Woodward) 22 */ 23 public class GeneratedClassFile { 24 private final String className; 25 private final byte[] contents; 26 27 /** 28 * @param name the fully qualified name of the class. 29 * @param classFileContents the binary contents of the file. 30 */ GeneratedClassFile(String name, byte[] classFileContents)31 public GeneratedClassFile(String name, byte[] classFileContents) { 32 className = name; 33 contents = classFileContents; 34 } 35 getClassName()36 public String getClassName() { 37 return className; 38 } 39 getContents()40 public byte[] getContents() { 41 return contents; 42 } 43 44 @Override hashCode()45 public int hashCode() { 46 return (this.getClass().getName() + className).hashCode(); 47 } 48 49 @Override equals(Object obj)50 public boolean equals(Object obj) { 51 return (obj instanceof GeneratedClassFile) 52 && className.equals(((GeneratedClassFile) obj).getClassName()); 53 } 54 } 55