// Path: src/main/java/at/grahsl/kafka/connect/mongodb/converter/SinkDocument.java
// public class SinkDocument {
// 
//     private final Optional<BsonDocument> keyDoc;
//     private final Optional<BsonDocument> valueDoc;
// 
//     public SinkDocument(BsonDocument keyDoc, BsonDocument valueDoc) {
//         this.keyDoc = Optional.ofNullable(keyDoc);
//         this.valueDoc = Optional.ofNullable(valueDoc);
//     }
// 
//     public Optional<BsonDocument> getKeyDoc() {
//         return keyDoc;
//     }
// 
//     public Optional<BsonDocument> getValueDoc() {
//         return valueDoc;
//     }
// 
//     public SinkDocument clone() {
//         BsonDocument kd = keyDoc.isPresent() ? keyDoc.get().clone() : null;
//         BsonDocument vd = valueDoc.isPresent() ? valueDoc.get().clone() : null;
//         return new SinkDocument(kd,vd);
//     }
// 
// }
// 
// Path: src/main/java/at/grahsl/kafka/connect/mongodb/processor/field/projection/FieldProjector.java
// public abstract class FieldProjector extends PostProcessor {
// 
//     public static final String SINGLE_WILDCARD = "*";
//     public static final String DOUBLE_WILDCARD = "**";
//     public static final String SUB_FIELD_DOT_SEPARATOR = ".";
// 
//     protected Set<String> fields;
//     
//     public FieldProjector(MongoDbSinkConnectorConfig config,String collection) {
//         super(config,collection);
//     }
// 
//     protected abstract void doProjection(String field, BsonDocument doc);
// 
// }


import at.grahsl.kafka.connect.mongodb.converter.SinkDocument;
import at.grahsl.kafka.connect.mongodb.processor.field.projection.FieldProjector;
import org.apache.kafka.connect.sink.SinkRecord;
import org.bson.BsonDocument;
import org.bson.BsonValue;
/*
 * Copyright (c) 2017. Hans-Peter Grahsl (grahslhp@gmail.com)
 *
 * 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 at.grahsl.kafka.connect.mongodb.processor.id.strategy;


public class PartialKeyStrategy implements IdStrategy {

    private FieldProjector fieldProjector;

    public PartialKeyStrategy(FieldProjector fieldProjector) {
        this.fieldProjector = fieldProjector;
    }

    @Override
// Path: src/main/java/at/grahsl/kafka/connect/mongodb/converter/SinkDocument.java
// public class SinkDocument {
// 
//     private final Optional<BsonDocument> keyDoc;
//     private final Optional<BsonDocument> valueDoc;
// 
//     public SinkDocument(BsonDocument keyDoc, BsonDocument valueDoc) {
//         this.keyDoc = Optional.ofNullable(keyDoc);
//         this.valueDoc = Optional.ofNullable(valueDoc);
//     }
// 
//     public Optional<BsonDocument> getKeyDoc() {
//         return keyDoc;
//     }
// 
//     public Optional<BsonDocument> getValueDoc() {
//         return valueDoc;
//     }
// 
//     public SinkDocument clone() {
//         BsonDocument kd = keyDoc.isPresent() ? keyDoc.get().clone() : null;
//         BsonDocument vd = valueDoc.isPresent() ? valueDoc.get().clone() : null;
//         return new SinkDocument(kd,vd);
//     }
// 
// }
// 
// Path: src/main/java/at/grahsl/kafka/connect/mongodb/processor/field/projection/FieldProjector.java
// public abstract class FieldProjector extends PostProcessor {
// 
//     public static final String SINGLE_WILDCARD = "*";
//     public static final String DOUBLE_WILDCARD = "**";
//     public static final String SUB_FIELD_DOT_SEPARATOR = ".";
// 
//     protected Set<String> fields;
//     
//     public FieldProjector(MongoDbSinkConnectorConfig config,String collection) {
//         super(config,collection);
//     }
// 
//     protected abstract void doProjection(String field, BsonDocument doc);
// 
// }


// Path: src/main/java/at/grahsl/kafka/connect/mongodb/processor/id/strategy/PartialKeyStrategy.java
import at.grahsl.kafka.connect.mongodb.converter.SinkDocument;
import at.grahsl.kafka.connect.mongodb.processor.field.projection.FieldProjector;
import org.apache.kafka.connect.sink.SinkRecord;
import org.bson.BsonDocument;
import org.bson.BsonValue;

/*
 * Copyright (c) 2017. Hans-Peter Grahsl (grahslhp@gmail.com)
 *
 * 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 at.grahsl.kafka.connect.mongodb.processor.id.strategy;


public class PartialKeyStrategy implements IdStrategy {

    private FieldProjector fieldProjector;

    public PartialKeyStrategy(FieldProjector fieldProjector) {
        this.fieldProjector = fieldProjector;
    }

    @Override
    public BsonValue generateId(SinkDocument doc, SinkRecord orig) {