// Path: src/main/java/com/github/mk23/jmxproxy/util/History.java
// public class History<T> {
//     private List<T> objects;
//     private int length;
//     private int pointer;
//     private boolean wrapped;
// 
//     /**
//      * <p>Default constructor.</p>
//      *
//      * Initializes the {@link Object} store {@link List} to the given history size.
//      *
//      * @param length number of {@link Object} values to keep in history.
//      */
//     public History(final int length) {
//         this.length = length;
// 
//         pointer = -1;
//         objects = new ArrayList<T>(Collections.nCopies(length, (T) null));
//     }
// 
//     /**
//      * <p>Adds a item to the store.</p>
//      *
//      * Adds a new item to the history store.  If the number of items exceeds the size
//      * of the store, the oldest item is overwritten.
//      *
//      * @param item newest item to add to the store.
//      */
//     public final void add(final T item) {
//         wrapped = ++pointer == length;
//         pointer = pointer % length;
// 
//         objects.set(pointer, item);
//     }
// 
//     /**
//      * <p>Gets the latest item from the history store.</p>
//      *
//      * Gets the latest single item from the history store.
//      *
//      * @return Latest item from the history store or null if empty.
//      */
//     public final T getLast() {
//         return pointer < 0 ? null : objects.get(pointer % length);
//     }
// 
//     /**
//      * <p>Gets the full item history from the store.</p>
//      *
//      * Gets the full item history from the store as a {@link List}.
//      *
//      * @return {@link List} of the full history.  May be empty if history has no items.
//      */
//     public final List<T> get() {
//         return get(length);
//     }
// 
//     /**
//      * <p>Gets a limited item history from the store.</p>
//      *
//      * Gets a limited history from the store as a {@link List}, based
//      * on requested item count.  If the specified count is less than 0 or greater than
//      * the number of entries, a full history is returned instead.
//      *
//      * @param limit number of items to retreive from the history store.
//      *
//      * @return {@link List} of the requested slice of history.  May be empty if history has no items.
//      */
//     public final List<T> get(final int limit) {
//         if (pointer < 0) {
//             return Collections.emptyList();
//         }
// 
//         int head = pointer + length * Boolean.compare(wrapped, false);
//         int size = Math.min(limit > 0 ? limit : Integer.MAX_VALUE, Math.min(head + 1, length));
//         List<T> rval = new ArrayList<T>(size);
// 
//         for (int i = 0; i < size; i++) {
//             rval.add(objects.get((head - i) % length));
//         }
// 
//         return rval;
//     }
// }


import com.github.mk23.jmxproxy.util.History;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializable;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
package com.github.mk23.jmxproxy.core;





/**
 * <p>JMX MBean tracker and serializer.</p>
 *
 * Maintains a map of JMX {@link Attribute} names and a {@link History} of
 * their values.  Implements JsonSerializable interface to convert the
 * stored map into JSON.
 *
 * @see <a href="https://fasterxml.github.io/jackson-databind/javadoc/2.6/com/fasterxml/jackson/databind/JsonSerializable.html">com.fasterxml.jackson.databind.JsonSerializable</a>
 *
 * @since   2018-02-08
 * @author  mk23
 * @version 3.4.0
 */
public class MBean implements JsonSerializable {
    private final int historySize;

// Path: src/main/java/com/github/mk23/jmxproxy/util/History.java
// public class History<T> {
//     private List<T> objects;
//     private int length;
//     private int pointer;
//     private boolean wrapped;
// 
//     /**
//      * <p>Default constructor.</p>
//      *
//      * Initializes the {@link Object} store {@link List} to the given history size.
//      *
//      * @param length number of {@link Object} values to keep in history.
//      */
//     public History(final int length) {
//         this.length = length;
// 
//         pointer = -1;
//         objects = new ArrayList<T>(Collections.nCopies(length, (T) null));
//     }
// 
//     /**
//      * <p>Adds a item to the store.</p>
//      *
//      * Adds a new item to the history store.  If the number of items exceeds the size
//      * of the store, the oldest item is overwritten.
//      *
//      * @param item newest item to add to the store.
//      */
//     public final void add(final T item) {
//         wrapped = ++pointer == length;
//         pointer = pointer % length;
// 
//         objects.set(pointer, item);
//     }
// 
//     /**
//      * <p>Gets the latest item from the history store.</p>
//      *
//      * Gets the latest single item from the history store.
//      *
//      * @return Latest item from the history store or null if empty.
//      */
//     public final T getLast() {
//         return pointer < 0 ? null : objects.get(pointer % length);
//     }
// 
//     /**
//      * <p>Gets the full item history from the store.</p>
//      *
//      * Gets the full item history from the store as a {@link List}.
//      *
//      * @return {@link List} of the full history.  May be empty if history has no items.
//      */
//     public final List<T> get() {
//         return get(length);
//     }
// 
//     /**
//      * <p>Gets a limited item history from the store.</p>
//      *
//      * Gets a limited history from the store as a {@link List}, based
//      * on requested item count.  If the specified count is less than 0 or greater than
//      * the number of entries, a full history is returned instead.
//      *
//      * @param limit number of items to retreive from the history store.
//      *
//      * @return {@link List} of the requested slice of history.  May be empty if history has no items.
//      */
//     public final List<T> get(final int limit) {
//         if (pointer < 0) {
//             return Collections.emptyList();
//         }
// 
//         int head = pointer + length * Boolean.compare(wrapped, false);
//         int size = Math.min(limit > 0 ? limit : Integer.MAX_VALUE, Math.min(head + 1, length));
//         List<T> rval = new ArrayList<T>(size);
// 
//         for (int i = 0; i < size; i++) {
//             rval.add(objects.get((head - i) % length));
//         }
// 
//         return rval;
//     }
// }


// Path: src/main/java/com/github/mk23/jmxproxy/core/MBean.java
import com.github.mk23.jmxproxy.util.History;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializable;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

package com.github.mk23.jmxproxy.core;





/**
 * <p>JMX MBean tracker and serializer.</p>
 *
 * Maintains a map of JMX {@link Attribute} names and a {@link History} of
 * their values.  Implements JsonSerializable interface to convert the
 * stored map into JSON.
 *
 * @see <a href="https://fasterxml.github.io/jackson-databind/javadoc/2.6/com/fasterxml/jackson/databind/JsonSerializable.html">com.fasterxml.jackson.databind.JsonSerializable</a>
 *
 * @since   2018-02-08
 * @author  mk23
 * @version 3.4.0
 */
public class MBean implements JsonSerializable {
    private final int historySize;

    private final Map<String, History<Attribute>> attributes;