<commit_before>/*
 * Copyright (c) 2008, <NAME>. All Rights Reserved.
 *
 * 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 org.qi4j.util;

import java.io.Serializable;
import java.lang.reflect.Type;
import java.lang.reflect.AnnotatedElement;
import java.lang.annotation.Annotation;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

/**
 * Used to declare and access metainfo about types.
 */
public final class MetaInfo
{
    private final Map<Class<?>, Object> metaInfoMap = new LinkedHashMap<Class<?>, Object>();

    public MetaInfo()
    {
    }

    public MetaInfo( MetaInfo metaInfo )
    {
        metaInfoMap.putAll( metaInfo.metaInfoMap );
    }

    public void set( Object metaInfo )
    {
        if (metaInfo instanceof Annotation)
        {
            metaInfoMap.put( metaInfo.getClass(), metaInfo );

        } else
        {
            Set<Class> types = ClassUtil.classesOf( metaInfo.getClass() );
            for( Type type : types )
            {
                if( type instanceof Class )
                {
                    metaInfoMap.put( (Class) type, metaInfo );
                }
            }
        }
    }

    public <T> T get( Class<T> metaInfoType )
    {
        return (T) metaInfoMap.get( metaInfoType );
    }

    public <T> void add( Class<T> infoType, T info )
    {<commit_msg>o Fix QI-73   o MetaInfo compute annotation class wrongly.<commit_after>/*
 * Copyright (c) 2008, <NAME>. All Rights Reserved.
 *
 * 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 org.qi4j.util;

import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Type;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;

/**
 * Used to declare and access metainfo about types.
 */
public final class MetaInfo
{
    private final Map<Class<?>, Object> metaInfoMap;

    public MetaInfo()
    {
        metaInfoMap = new LinkedHashMap<Class<?>, Object>();
    }

    public MetaInfo( MetaInfo metaInfo )
    {
        metaInfoMap = new LinkedHashMap<Class<?>, Object>();
        metaInfoMap.putAll( metaInfo.metaInfoMap );
    }

    public void set( Object metaInfo )
    {
        if( metaInfo instanceof Annotation )
        {
            Annotation annotation = (Annotation) metaInfo;
            metaInfoMap.put( annotation.annotationType(), metaInfo );
        }
        else
        {
            Class<? extends Object> metaInfoclass = metaInfo.getClass();
            Set<Class> types = ClassUtil.classesOf( metaInfoclass );
            for( Type type : types )
            {
                if( type instanceof Class )
                {
                    metaInfoMap.put( (Class) type, metaInfo );
                }
            }
        }
    }

    public <T> T get( Class<T> metaInfoType )
    {
        return (T) metaInfoMap.get( metaInfoType );
    }

    public <T> void add( Class<T> infoType, T info )
    {
{'fraction_non_alphanumeric': 0.0952020202020202, 'fraction_numerical': 0.005050505050505051, 'mean_word_length': 2.456369982547993, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5207600', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1076, 'n_words': 374}