/*
 * Copyright (c) 2008-2016 Haulmont.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package com.haulmont.chile.core.annotations;

import com.haulmont.cuba.core.entity.annotation.MetaAnnotation;

import java.lang.annotation.Target;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Defines an instance name format pattern in the form {0}|{1}, where
 * <ul>
 *     <li>{0} - format string as for {@link String#format}, or a name of this object method, returning string,
 *     with {@code #} symbol in the beginning.</li>
 *     <li>{1} - comma-separated list of field names, corresponding to format {0}. These fields are also used for
 *     defining a {@code _minimal} view of this entity.</li>
 * </ul>
 * Extra spaces between parts are not allowed.
 *
 * <br> Format string example: {@code @NamePattern("%s : %s|name,address")}
 *
 * <br> Method example:
 * {@code @NamePattern("#getCaption|login,name")}
 * <pre>
 * public class User extends StandardEntity {
 * ...
 *     public String getCaption() {
 *         String pattern = AppContext.getProperty("cuba.user.namePattern");
 *         if (StringUtils.isBlank(pattern)) {
 *             pattern = "{1} [{0}]";
 *         }
 *         MessageFormat fmt = new MessageFormat(pattern);
 *         return fmt.format(new Object[] {login, name});
 *     }
 * }
 * </pre>
 */
@Target({java.lang.annotation.ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@MetaAnnotation
public @interface NamePattern {
    String value();
}
@@ -947,42 +947,249 @@
 ing 
-as for %7B@link String#format%7D, or a
+which can be one of two types:%0A *     %3Cul%3E%0A *      %3Cli%3EA string with %7B@code %25s%7D placeholders for formatted values of entity attributes.%0A *          Attribute values are formatted to strings according to their %7B@code Datatype%7Ds.%0A *      %3Cli%3EA
  nam
@@ -1230,23 +1230,16 @@
  string,
-%0A *    
  with %7B@
@@ -1270,20 +1270,28 @@
 ginning.
-%3C/li
+%0A *     %3C/ul
 %3E%0A *    
@@ -1521,39 +1521,57 @@
 .%0A *
-%0A * %3Cbr%3E Format string example:
+ %3Cp%3E%0A * Attribute placeholders example:%0A * %3Cp%3E%0A *
  %7B@c
@@ -1618,16 +1618,15 @@
 %7D%0A *
-%0A * %3Cbr%3E
+ %3Cp%3E%0A *
  Met
@@ -1638,16 +1638,32 @@
 xample:%0A
+ * %3Cp%3E%0A * %3Cpre%3E%0A
  * %7B@cod
@@ -1694,30 +1694,23 @@
 ion%7C
-login,name%22)%7D%0A * %3Cpre%3E
+name,address%22)%7D
 %0A * 
@@ -1726,12 +1726,11 @@
 ass 
-User
+Foo
  ext
@@ -1809,287 +1809,37 @@
     
-String pattern = AppContext.getProperty(%22cuba.user.namePattern%22);%0A *         if (StringUtils.isBlank(pattern)) %7B%0A *             pattern = %22%7B1%7D %5B%7B0%7D%5D%22;%0A *         %7D%0A *         MessageFormat fmt = new MessageFormat(pattern);%0A *         return fmt.format(new Object%5B%5D %7Blogin, name%7D)
+return name + %22 : %22 + address
 ;%0A *

Fix NamePattern Javadoc