All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.testcontainers.images.builder.traits.StringsTrait Maven / Gradle / Ivy

There is a newer version: 1.20.3
Show newest version
package org.testcontainers.images.builder.traits;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
import org.testcontainers.images.builder.Transferable;

/**
 * BuildContextBuilder's trait for String-based manipulations.
 *
 */
public interface StringsTrait & BuildContextBuilderTrait> {
    default SELF withFileFromString(String path, String content) {
        return ((SELF) this).withFileFromTransferable(
                path,
                new Transferable() {
                    @Getter
                    byte[] bytes = content.getBytes();

                    @Override
                    public long getSize() {
                        return bytes.length;
                    }

                    @Override
                    public String getDescription() {
                        return "String: " + StringUtils.abbreviate(content, 100);
                    }
                }
            );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy