1/*2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements. See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership. The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License. You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */18package org.apache.giraph.jython.wrappers;
1920import org.python.core.PyObject;
2122import com.google.common.base.Objects;
2324// CHECKSTYLE: stop MethodNameCheck2526/**27 * Base class for wrapping Jython objects28 */29publicclassJythonWrapperBaseextends PyObject {
30/** The Jython object being wrapped */31private PyObject pyObject;
3233/**34 * Constructor35 *36 * @param pyObject Jython object to wrap37 */38publicJythonWrapperBase(PyObject pyObject) {
39this.pyObject = pyObject;
40 }
4142public PyObject getPyObject() {
43return pyObject;
44 }
4546publicvoid setPyObject(PyObject pyObject) {
47this.pyObject = pyObject;
48 }
4950 @Override
51public PyObject __findattr_ex__(String name) {
52return pyObject.__findattr_ex__(name);
53 }
5455 @Override
56publicvoid __setattr__(String name, PyObject value) {
57 pyObject.__setattr__(name, value);
58 }
5960 @Override
61publicboolean equals(Object obj) {
62if (obj == null) {
63return false;
64 }
65if (this == obj) {
66returntrue;
67 }
68if (obj instanceof JythonWrapperBase) {
69JythonWrapperBase other = (JythonWrapperBase) obj;
70return Objects.equal(pyObject, other.pyObject);
71 }
72return false;
73 }
7475 @Override
76publicint hashCode() {
77return Objects.hashCode(pyObject);
78 }
79 }
8081// CHECKSTYLE: resume MethodNameCheck