@@ -137,23 +137,42 @@ public List<String> check(Map<K, V> value) {
137137 final String escape = TEMPLATE_SETTINGS .get ("escape" );
138138 String result = template ;
139139 final List <String > notFound = new ArrayList <String >();
140+ final List <String > valueKeys = new ArrayList <String >();
140141 for (final Map .Entry <K , V > element : value .entrySet ()) {
142+ final String key = "" + ((Map .Entry ) element ).getKey ();
141143 java .util .regex .Matcher matcher = java .util .regex .Pattern .compile (interpolate .replace (ALL_SYMBOLS ,
142- "\\ s*\\ Q" + (( Map . Entry ) element ). getKey () + "\\ E\\ s*" )).matcher (result );
144+ "\\ s*\\ Q" + key + "\\ E\\ s*" )).matcher (result );
143145 boolean isFound = matcher .find ();
144146 result = matcher .replaceAll (String .valueOf (((Map .Entry ) element ).getValue ()));
145147 matcher = java .util .regex .Pattern .compile (escape .replace (ALL_SYMBOLS ,
146- "\\ s*\\ Q" + (( Map . Entry ) element ). getKey () + "\\ E\\ s*" )).matcher (result );
148+ "\\ s*\\ Q" + key + "\\ E\\ s*" )).matcher (result );
147149 isFound |= matcher .find ();
148150 result = matcher .replaceAll (escape (String .valueOf (((Map .Entry ) element ).getValue ())));
149151 matcher = java .util .regex .Pattern .compile (evaluate .replace (ALL_SYMBOLS ,
150- "\\ s*\\ Q" + (( Map . Entry ) element ). getKey () + "\\ E\\ s*" )).matcher (result );
152+ "\\ s*\\ Q" + key + "\\ E\\ s*" )).matcher (result );
151153 isFound |= matcher .find ();
152154 result = matcher .replaceAll (String .valueOf (((Map .Entry ) element ).getValue ()));
153155 if (!isFound ) {
154- notFound .add ("" + (( Map . Entry ) element ). getKey () );
156+ notFound .add (key );
155157 }
158+ valueKeys .add (key );
156159 }
160+ final List <String > templateVars = new ArrayList <String >();
161+ java .util .regex .Matcher matcher = java .util .regex .Pattern .compile (interpolate ).matcher (result );
162+ while (matcher .find ()) {
163+ templateVars .add (matcher .group (1 ).trim ());
164+ }
165+ result = matcher .replaceAll ("" );
166+ matcher = java .util .regex .Pattern .compile (escape ).matcher (result );
167+ while (matcher .find ()) {
168+ templateVars .add (matcher .group (1 ).trim ());
169+ }
170+ result = matcher .replaceAll ("" );
171+ matcher = java .util .regex .Pattern .compile (evaluate ).matcher (result );
172+ while (matcher .find ()) {
173+ templateVars .add (matcher .group (1 ).trim ());
174+ }
175+ notFound .addAll (difference (templateVars , valueKeys ));
157176 return notFound ;
158177 }
159178 }
0 commit comments