001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 package org.apache.oozie; 019 020 import java.io.DataInput; 021 import java.io.DataOutput; 022 import java.io.IOException; 023 024 import javax.persistence.Embeddable; 025 026 import org.apache.hadoop.io.Writable; 027 import org.apache.oozie.util.WritableUtils; 028 029 /** 030 * The composite primary key for the BundleActionBean Entity. 031 */ 032 @Embeddable 033 public class BundleActionId implements Writable { 034 private String bundleId = null; 035 private String coordName = null; 036 037 /** 038 * Set the Bundle Id 039 * 040 * @param bundleId the bundleId to set 041 */ 042 public void setBundleId(String bundleId) { 043 this.bundleId = bundleId; 044 } 045 046 /** 047 * Return the Bundle Id. 048 * 049 * @return the bundleId 050 */ 051 public String getBundleId() { 052 return bundleId; 053 } 054 055 /** 056 * Set the coordinator name 057 * 058 * @param coordName the coordName to set 059 */ 060 public void setCoordName(String coordName) { 061 this.coordName = coordName; 062 } 063 064 /** 065 * Return the coordinator name 066 * 067 * @return the coordName 068 */ 069 public String getCoordName() { 070 return coordName; 071 } 072 073 /* (non-Javadoc) 074 * @see java.lang.Object#hashCode() 075 */ 076 @Override 077 public int hashCode() { 078 return new String(bundleId + coordName).hashCode(); 079 } 080 081 /* (non-Javadoc) 082 * @see java.lang.Object#equals(java.lang.Object) 083 */ 084 @Override 085 public boolean equals(Object obj) { 086 if (obj instanceof BundleActionId) { 087 return bundleId.equals(((BundleActionId) obj).getBundleId()) 088 && coordName.equals(((BundleActionId) obj).getCoordName()); 089 } 090 else { 091 return false; 092 } 093 } 094 095 /* (non-Javadoc) 096 * @see org.apache.hadoop.io.Writable#readFields(java.io.DataInput) 097 */ 098 @Override 099 public void readFields(DataInput dataInput) throws IOException { 100 setBundleId(WritableUtils.readStr(dataInput)); 101 setCoordName(WritableUtils.readStr(dataInput)); 102 } 103 104 /* (non-Javadoc) 105 * @see org.apache.hadoop.io.Writable#write(java.io.DataOutput) 106 */ 107 @Override 108 public void write(DataOutput dataOutput) throws IOException { 109 WritableUtils.writeStr(dataOutput, getBundleId()); 110 WritableUtils.writeStr(dataOutput, getCoordName()); 111 } 112 }