ActiveObject - util model method

b April 4, 2012

Hi,

Is that possible to create method with nonpersistable field.

public interface A extends Entity {

    public void setB(String B);
    public String getB();

    public String doSth();
}

I want to for example, method doSth do additional operations like duplication of B object

1 answer

1 accepted

2 votes
Answer accepted
Remo Siegwart
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 4, 2012

You could use implementation classes as described in Implementing the Active Record Pattern to do additional operations like:

@Implementation(CompanyImpl.class)
public interface Company extends Entity {
	// ...
}

public class CompanyImpl {
	private Company company;
	
	public CompanyImpl(Company company) {
		this.company = company;
	}
	
	public void setName(String name) {
		company.setName(name);
		
		name = name.trim();
		if (name.length() > 4) {
			company.setTickerSymbol(name.substring(0, 4).toUpperCase());
		} else {
			company.setTickerSymbol(name.toUpperCase());
		}
	}
}

Hope this helps

Suggest an answer

Log in or Sign up to answer