001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.commons.bean;
018
019/**
020 * Bean-modeling SPI seam that applies marshalling-side post-processing to a {@code BeanPropertyMeta.Builder}
021 * after {@code BeanPropertyMeta.Builder#validate()} succeeds.
022 *
023 * <p>
024 * On the marshalling-side path, post-processing reads {@code @MarshalledProp} / {@code @Swap} / {@code @Uri}
025 * annotations and installs swap-aware read/write transforms on the builder.  The bean-modeling layer in
026 * {@code commons.bean} never touches those marshalling-side concerns directly; it just invokes this hook.
027 *
028 * <p>
029 * The default {@link #NOOP} implementation does nothing and is wired on the commons-side path.
030 *
031 * <p>
032 * The {@code marshallingContext} parameter remains {@link Object} so this commons-side SPI does not depend
033 * on marshalling-side runtime types.
034 *
035 * <h5 class='topic'>Thread safety</h5>
036 * Thread safety depends on implementation.
037 *
038 * @see BeanConfigContext.Builder#beanPropertyPostProcessor(BeanPropertyPostProcessor)
039 */
040@FunctionalInterface
041public interface BeanPropertyPostProcessor {
042
043   /** Singleton commons-side default — no marshalling-side post-processing. */
044   BeanPropertyPostProcessor NOOP = (marshallingContext, builder) -> {};
045
046   /**
047    * Applies marshalling-side post-processing to the supplied builder.
048    *
049    * @param marshallingContext The marshalling-side context (as an opaque {@link Object}).  May be <jk>null</jk>
050    * when invoked from the commons-side construction path.
051    * @param builder The bean-property builder to mutate.  Must not be <jk>null</jk>.
052    */
053   void process(Object marshallingContext, BeanPropertyMeta.Builder builder);
054}