|
Groovy example source code file (DummyBean.java)
The Groovy DummyBean.java source code
/*
* Copyright 2003-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.codehaus.groovy.runtime;
import java.awt.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.util.HashMap;
import java.util.Map;
/**
* A bean used by the test cases
*
* @author <a href="mailto:james@coredevelopers.net">James Strachan
* @author <a href="mailto:shemnon@yahoo.com">Danno Ferrin
* @version $Revision: 21515 $
*/
public class DummyBean {
private String name = "James";
private Integer i = new Integer(123);
private Map dynamicProperties = new HashMap();
private Point point;
private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
public DummyBean() {
}
public DummyBean(String name) {
this.name = name;
}
public DummyBean(String name, Integer i) {
this.name = name;
this.i = i;
}
public void addPropertyChangeListener(PropertyChangeListener listener) {
changeSupport.addPropertyChangeListener(listener);
}
public Integer getI() {
return i;
}
public void setI(Integer i) {
changeSupport.firePropertyChange("i", this.i, this.i = i);
}
public String getName() {
return name;
}
public void setName(String name) {
changeSupport.firePropertyChange("name", this.name, this.name = name);
}
// dynamic properties
public Object get(String property) {
return dynamicProperties.get(property);
}
public void set(String property, Object newValue) {
dynamicProperties.put(property, newValue);
}
public static String dummyStaticMethod(String text) {
return text.toUpperCase();
}
public boolean equals(Object that) {
if (that instanceof DummyBean) {
return equals((DummyBean) that);
}
return false;
}
public boolean equals(DummyBean that) {
return this.name.equals(that.name) && this.i.equals(that.i);
}
public String toString() {
return super.toString() + "[name=" + name + ";i=" + i + "]";
}
public Point getPoint() {
return point;
}
public void setPoint(Point point) {
changeSupport.firePropertyChange("point", this.point, this.point = point);
}
}
Other Groovy examples (source code examples)Here is a short list of links related to this Groovy DummyBean.java source code file: |
Other websites by Alvin Alexander:
Life/living in Alaska (OneMansAlaska.com)
How I Sold My Business (HowISoldMyBusiness.com)
Copyright 1998-2011 Alvin Alexander, devdaily.com
All Rights Reserved.