001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *        http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 */
019
020package org.apache.isis.core.metamodel.services.container.query;
021
022import java.io.Serializable;
023import java.text.MessageFormat;
024
025import org.apache.isis.applib.query.Query;
026import org.apache.isis.applib.query.QueryBuiltInAbstract;
027
028/**
029 * Although implements {@link Query} and thus is intended to be (and indeed is)
030 * {@link Serializable}, it will be converted into a <tt>PersistenceQuery</tt>
031 * in the runtime for remoting purposes.
032 * 
033 * <p>
034 * See discussion in {@link QueryBuiltInAbstract} for further details.
035 */
036public class QueryFindByTitle<T> extends QueryBuiltInAbstract<T> {
037
038    private static final long serialVersionUID = 1L;
039
040    private final String title;
041
042    public QueryFindByTitle(final Class<T> type, final String title, final long ... range) {
043        super(type, range);
044        this.title = title;
045    }
046    
047    public String getTitle() {
048        return title;
049    }
050
051    @Override
052    public String getDescription() {
053        return MessageFormat.format("{0} (matching title: '{1}')", getResultTypeName(), getTitle());
054    }
055
056}