All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.mmm.property.builder.lang.RangePropertyBuilder Maven / Gradle / Ivy

/* 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.property.builder.lang;

import io.github.mmm.base.range.Range;
import io.github.mmm.property.AttributeReadOnly;
import io.github.mmm.property.PropertyMetadata;
import io.github.mmm.property.builder.PropertyBuilder;
import io.github.mmm.property.object.SimpleProperty;
import io.github.mmm.property.range.RangeProperty;
import io.github.mmm.property.string.StringProperty;
import io.github.mmm.validation.range.ValidatorBuilderRange;

/**
 * {@link PropertyBuilder} for {@link StringProperty}.
 *
 * @param  type of the {@link Range} bounds.
 * @since 1.0.0
 */
public final class RangePropertyBuilder> extends
    PropertyBuilder, RangeProperty, ValidatorBuilderRange>, RangePropertyBuilder> {

  private SimpleProperty valueProperty;

  /**
   * The constructor.
   *
   * @param lock the {@link #getLock() lock}.
   */
  public RangePropertyBuilder(AttributeReadOnly lock) {

    this(lock, null);
  }

  /**
   * The constructor.
   *
   * @param lock the {@link PropertyMetadata#getLock() lock}.
   * @param valueProperty the {@link RangeProperty#getValueProperty() value property}.
   */
  public RangePropertyBuilder(AttributeReadOnly lock, SimpleProperty valueProperty) {

    super(lock);
    this.valueProperty = valueProperty;
  }

  /**
   * @param property the {@link RangeProperty#getValueProperty() value property}.
   * @return this builder itself ({@code this}) for fluent API calls.
   */
  public RangePropertyBuilder valueProperty(SimpleProperty property) {

    this.valueProperty = property;
    return this;
  }

  @Override
  protected ValidatorBuilderRange> createValidatorBuilder() {

    return new ValidatorBuilderRange<>(this);
  }

  @Override
  protected RangeProperty build(String name, PropertyMetadata> metadata) {

    return new RangeProperty<>(name, this.valueProperty, metadata);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy