1 /** 2 * Copyright 2006-2017 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package org.objenesis.tck.search; 17 18 import org.objenesis.instantiator.annotations.Instantiator; 19 import org.objenesis.instantiator.annotations.Typology; 20 21 /** 22 * @author Henri Tremblay 23 */ 24 public class SystemOutListener implements SearchWorkingInstantiatorListener { 25 26 private static final String PATTERN = "%-65s: %s%n"; 27 28 public void instantiatorSupported(Class<?> c) { 29 System.out.printf(PATTERN, c.getSimpleName() + " (" + getTypology(c) + ")", "Working!"); 30 } 31 32 public void instantiatorUnsupported(Class<?> c, Throwable t) { 33 System.out.printf(PATTERN, c.getSimpleName() + "(" + getTypology(c) + ")", "KO - " + t); 34 } 35 36 private Typology getTypology(Class<?> c) { 37 Instantiator instantiatorAnn = c.getAnnotation(Instantiator.class); 38 return instantiatorAnn == null ? Typology.UNKNOWN : instantiatorAnn.value(); 39 } 40 } 41