@Test public void testAttributeAppliesToView() { final ModelAttributeService modelAttributeService = new ModelAttributeService(); final SoffitModelAttribute unspecific = new BaseSoffitModelAttribute() { @Override public String value() { return "unspecific"; } @Override public String viewRegex() { return ".*"; } }; final SoffitModelAttribute specific = new BaseSoffitModelAttribute() { @Override public String value() { return "specific"; } @Override public String viewRegex() { return "specific"; } }; final String[] unspecificViewNames = new String[] {"apereo", "uPortal", "open source"}; for (String name : unspecificViewNames) { assertTrue( "View name '" + name + "' should apply to model attribute: " + unspecific, modelAttributeService.attributeAppliesToView(unspecific, name)); assertFalse( "View name '" + name + "' should NOT apply to model attribute: " + specific, modelAttributeService.attributeAppliesToView(specific, name)); } final String specificName = "specific"; assertTrue( "View name '" + specificName + "' should apply to model attribute: " + specific, modelAttributeService.attributeAppliesToView(unspecific, specificName)); }
protected boolean attributeAppliesToView( SoffitModelAttribute attributeAnnotation, String viewName) { final Pattern pattern = Pattern.compile(attributeAnnotation.viewRegex()); final Matcher matcher = pattern.matcher(viewName); return matcher.matches(); }
ModelAttributeService { protected boolean attributeAppliesToView( SoffitModelAttribute attributeAnnotation, String viewName) { final Pattern pattern = Pattern.compile(attributeAnnotation.viewRegex()); final Matcher matcher = pattern.matcher(viewName); return matcher.matches(); } }
ModelAttributeService { protected boolean attributeAppliesToView( SoffitModelAttribute attributeAnnotation, String viewName) { final Pattern pattern = Pattern.compile(attributeAnnotation.viewRegex()); final Matcher matcher = pattern.matcher(viewName); return matcher.matches(); }  }
ModelAttributeService { protected boolean attributeAppliesToView( SoffitModelAttribute attributeAnnotation, String viewName) { final Pattern pattern = Pattern.compile(attributeAnnotation.viewRegex()); final Matcher matcher = pattern.matcher(viewName); return matcher.matches(); }  @PostConstruct void init(); }
ModelAttributeService { protected boolean attributeAppliesToView( SoffitModelAttribute attributeAnnotation, String viewName) { final Pattern pattern = Pattern.compile(attributeAnnotation.viewRegex()); final Matcher matcher = pattern.matcher(viewName); return matcher.matches(); }  @PostConstruct void init();  }