-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
m-m-m/bean#7: getReadOnly() and WritableBean constructor
- Loading branch information
Showing
2 changed files
with
66 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 51 additions & 39 deletions
90
shared/src/main/java/io/github/mmm/ui/demo/shared/place/content/widget/data/TestBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,51 @@ | ||
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 */ | ||
package io.github.mmm.ui.demo.shared.place.content.widget.data; | ||
|
||
import io.github.mmm.bean.AbstractBean; | ||
import io.github.mmm.bean.Bean; | ||
import io.github.mmm.bean.BeanName; | ||
import io.github.mmm.property.number.integers.IntegerProperty; | ||
import io.github.mmm.property.string.StringProperty; | ||
|
||
/** | ||
* A {@link Bean} for testing. | ||
*/ | ||
@BeanName("mmm.TestBean") | ||
public class TestBean extends Bean { | ||
|
||
/** Full name of person. */ | ||
public final StringProperty Name; | ||
|
||
/** Age of person. */ | ||
public final IntegerProperty Age; | ||
|
||
/** | ||
* The constructor. | ||
*/ | ||
public TestBean() { | ||
|
||
super(); | ||
this.Name = add().newString().withValidator().mandatory().and().build("Name"); | ||
this.Age = add().newInteger("Age"); | ||
} | ||
|
||
@Override | ||
protected AbstractBean create() { | ||
|
||
return new TestBean(); | ||
} | ||
|
||
} | ||
/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 */ | ||
package io.github.mmm.ui.demo.shared.place.content.widget.data; | ||
|
||
import io.github.mmm.bean.AbstractBean; | ||
import io.github.mmm.bean.Bean; | ||
import io.github.mmm.bean.BeanName; | ||
import io.github.mmm.bean.WritableBean; | ||
import io.github.mmm.property.number.integers.IntegerProperty; | ||
import io.github.mmm.property.string.StringProperty; | ||
|
||
/** | ||
* A {@link Bean} for testing. | ||
*/ | ||
@BeanName("mmm.TestBean") | ||
public class TestBean extends Bean { | ||
|
||
/** Full name of person. */ | ||
public final StringProperty Name; | ||
|
||
/** Age of person. */ | ||
public final IntegerProperty Age; | ||
|
||
/** | ||
* The constructor. | ||
*/ | ||
public TestBean() { | ||
|
||
this(null); | ||
} | ||
|
||
/** | ||
* The constructor. | ||
* | ||
* @param writable the {@link WritableBean} to wrap as {@link #isReadOnly() read-only} bean or {@code null} to create | ||
* a mutable bean. | ||
*/ | ||
public TestBean(WritableBean writable) { | ||
|
||
super(writable); | ||
this.Name = add().newString().withValidator().mandatory().and().build("Name"); | ||
this.Age = add().newInteger("Age"); | ||
} | ||
|
||
@Override | ||
protected AbstractBean create(WritableBean writable) { | ||
|
||
return new TestBean(writable); | ||
} | ||
|
||
} |