    001// Copyright 2007, 2010, 2013 The Apache Software Foundation
    002//
    003// Licensed under the Apache License, Version 2.0 (the "License");
    004// you may not use this file except in compliance with the License.
    005// You may obtain a copy of the License at
    006//
    007// http://www.apache.org/licenses/LICENSE-2.0
    008//
    009// Unless required by applicable law or agreed to in writing, software
    010// distributed under the License is distributed on an "AS IS" BASIS,
    011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012// See the License for the specific language governing permissions and
    013// limitations under the License.
    014
    015package org.apache.tapestry5.services;
    016
    017import org.apache.tapestry5.corelib.components.Label;
    018import org.apache.tapestry5.ioc.internal.util.InternalUtils;
    019
    020/**
    021 * A contribution to the {@link BeanBlockSource} service, defining a page name and block id (within the page) that can
    022 * edit or display a particular type of property.
    023 */
    024public class BeanBlockContribution
    025{
    026    private final String dataType;
    027
    028    private final String pageName;
    029
    030    private final String blockId;
    031
    032    private final boolean edit;
    033
    034    protected BeanBlockContribution(String dataType, String pageName, String blockId, boolean edit)
    035    {
    036        assert InternalUtils.isNonBlank(dataType);
    037        assert InternalUtils.isNonBlank(pageName);
    038        assert InternalUtils.isNonBlank(blockId);
    039        this.dataType = dataType;
    040        this.pageName = pageName;
    041        this.blockId = blockId;
    042        this.edit = edit;
    043    }
    044
    045    /**
    046     * The type of data for which the indicated block will provide an editor or displayer for.
    047     */
    048    public final String getDataType()
    049    {
    050        return dataType;
    051    }
    052
    053    /**
    054     * The id of the block within the page.
    055     */
    056    public final String getBlockId()
    057    {
    058        return blockId;
    059    }
    060
    061    /**
    062     * If true, then the block provides an editor for the property, consisting of a {@link Label} and some field
    063     * component (or set of field components). If false, the block is used to display the value of the property, usually
    064     * by applying some kind of formatting to the raw value.
    065     */
    066    public final boolean isEdit()
    067    {
    068        return edit;
    069    }
    070
    071    /**
    072     * The logical name of the page containing the block.
    073     */
    074    public final String getPageName()
    075    {
    076        return pageName;
    077    }
    078
    079}